https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110196
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Last reconfirmed| |2023-06-09
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to [email protected] from comment #3)
> Also, backtrace_create_state is ment to be called just once per execution,
> because it allocates unfreeable memory. Maybe, a singleton would be the way
> to go here.
It is only called once, isn't it?
(In reply to [email protected] from comment #5)
> Indeed, changing _S_init to the following improved it:
>
> ```
> static backtrace_state *_S_init() {
>
> static backtrace_state *__state = []() {
> auto getpath = []() -> std::string {
> char buf[PATH_MAX + 1];
> if (readlink("/proc/self/exe", buf, sizeof(buf) - 1) == -1) {
This isn't portable, not all systems have /proc/self/exe, or readlink.
I think it would be better to move this function into the library, and use
std::filesystem::read_symlink.