From 7cb865527709cea8d7ebdd8e74f5e873fd132062 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 12 Dec 2024 00:04:44 -0500 Subject: [PATCH] Warm up backtrace() --- src/libraries/JANA/CLI/JSignalHandler.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libraries/JANA/CLI/JSignalHandler.cc b/src/libraries/JANA/CLI/JSignalHandler.cc index 2ef87f4d8..dfb019b5c 100644 --- a/src/libraries/JANA/CLI/JSignalHandler.cc +++ b/src/libraries/JANA/CLI/JSignalHandler.cc @@ -71,6 +71,13 @@ void register_handlers(JApplication* app) { // It would be nice to do this in a less unexpected place, and hopefully that will naturally // emerge from future refactorings. + // We capture a dummy backtrace to warm it up before it gets called inside a signal handler. + // Because backtrace() dynamically loads libgcc, calling malloc() in the process, it is not + // async-signal-safe until this warmup has happened. Thus we prevent a rare deadlock and several + // TSAN and Helgrind warnings. + JBacktrace backtrace; + backtrace.Capture(); + //Define signal action struct sigaction sSignalAction; sSignalAction.sa_sigaction = handle_sigsegv;