Hello All,
I just discovered that backtrace_create_state should be called once,
that it is returning some heap-allocated data (which cannot be free-d,
because there is no
backtrace_destroy_state routine).
I suggest the attached patch (against GCC trunk r246678) which just
improves the comment describing that function.
libgcc/ChangeLog entry:
2017-04-04 Basile Starynkevitch <bas...@starynkevitch.net>
* backtrace.h (backtrace_create_state): Improve comment, since
should be called once.
Comments are welcome. Otherwise, ok for trunk?
--
Basile Starynkevitch (France)
http://starynkevitch.net/Basile/
Index: libbacktrace/backtrace.h
===================================================================
--- libbacktrace/backtrace.h (revision 246678)
+++ libbacktrace/backtrace.h (working copy)
@@ -83,16 +83,17 @@
int errnum);
/* Create state information for the backtrace routines. This must be
- called before any of the other routines, and its return value must
- be passed to all of the other routines. FILENAME is the path name
- of the executable file; if it is NULL the library will try
- system-specific path names. If not NULL, FILENAME must point to a
- permanent buffer. If THREADED is non-zero the state may be
- accessed by multiple threads simultaneously, and the library will
- use appropriate atomic operations. If THREADED is zero the state
- may only be accessed by one thread at a time. This returns a state
- pointer on success, NULL on error. If an error occurs, this will
- call the ERROR_CALLBACK routine. */
+ called once before any of the other routines (probably at startup,
+ e.g. early in main), and its return value must be passed to all of
+ the other routines. FILENAME is the path name of the executable
+ file; if it is NULL the library will try system-specific path
+ names. If not NULL, FILENAME must point to a permanent buffer. If
+ THREADED is non-zero the state may be accessed by multiple threads
+ simultaneously, and the library will use appropriate atomic
+ operations. If THREADED is zero the state may only be accessed by
+ one thread at a time. This returns a state pointer on success,
+ NULL on error. If an error occurs, this will call the
+ ERROR_CALLBACK routine. */
extern struct backtrace_state *backtrace_create_state (
const char *filename, int threaded,