[Bug libbacktrace/87529] New: libbacktrace API forces users to have memory leaks
antoshkka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Oct 5 13:52:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87529
Bug ID: 87529
Summary: libbacktrace API forces users to have memory leaks
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libbacktrace
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
CC: ian at gcc dot gnu.org
Target Milestone: ---
Function for creating state `backtrace_create_state` returns a pointer to
`struct backtrace_state`.
There's no function to free the state so the users assume that the pointer
returned from `backtrace_create_state` is a pointer to some static variable
that should not be freed... Which is not true. `struct backtrace_state` is
dynamically allocated.
Multiple usages of `backtrace_create_state` consume all the available memory
and lead to segfaults.
Please add `backtrace_free_state` function that frees the resources allocated
by `backtrace_create_state` and document that state returned by
`backtrace_create_state` should be freed.
Another way to solve the problem is to
* always return the same state `backtrace_create_state` and override the
`threaded` argument with 1
* free that state on exit
More information about the Gcc-bugs
mailing list