https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88137

--- Comment #4 from Janne Blomqvist <jb at gcc dot gnu.org> ---
Author: jb
Date: Fri Nov 30 16:44:27 2018
New Revision: 266677

URL: https://gcc.gnu.org/viewcvs?rev=266677&root=gcc&view=rev
Log:
Initialize backtrace state once

From backtrace.h for backtrace_create_state:

   Calling this function allocates resources that can not be freed.
   There is no backtrace_free_state function.  The state is used to
   cache information that is expensive to recompute.  Programs are
   expected to call this function at most once and to save the return
   value for all later calls to backtrace functions.

So instead of calling backtrace_create_state every time we wish to
show a backtrace, do it once and store the result in a static
variable.  libbacktrace allows multiple threads to access the state,
so no need to use TLS.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2018-11-30  Janne Blomqvist  <j...@gcc.gnu.org>

        PR libfortran/88137
        * runtime/backtrace.c (show_backtrace): Make lbstate a static
        variable, initialize once.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/runtime/backtrace.c

Reply via email to