+2018-12-02 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/88137
+ * runtime/backtrace.c (show_backtrace): Use atomic load/store to
+ access the static lbstate pointer.
+
2018-11-30 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/88137
/* Note that libbacktrace allows the state to be accessed from
multiple threads, so we don't need to use a TLS variable for the
state here. */
- static struct backtrace_state *lbstate;
+ static struct backtrace_state *lbstate_saved;
+ struct backtrace_state *lbstate;
struct mystate state = { 0, false, in_signal_handler };
+ lbstate = __atomic_load_n (&lbstate_saved, __ATOMIC_RELAXED);
if (!lbstate)
- lbstate = backtrace_create_state (NULL, __gthread_active_p (),
- error_callback, NULL);
-
- if (lbstate == NULL)
- return;
+ {
+ lbstate = backtrace_create_state (NULL, __gthread_active_p (),
+ error_callback, NULL);
+ if (lbstate)
+ __atomic_store_n (&lbstate_saved, lbstate, __ATOMIC_RELAXED);
+ else
+ return;
+ }
if (!BACKTRACE_SUPPORTED || (in_signal_handler && BACKTRACE_USES_MALLOC))
{