https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88137
--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> --- Author: jb Date: Fri Nov 30 16:46:55 2018 New Revision: 266678 URL: https://gcc.gnu.org/viewcvs?rev=266678&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. Backport from trunk. 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: branches/gcc-8-branch/libgfortran/ChangeLog branches/gcc-8-branch/libgfortran/runtime/backtrace.c