Skip to content

Commit

Permalink
Warm up backtrace()
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwbrei committed Dec 12, 2024
1 parent e8b5e36 commit 7cb8655
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libraries/JANA/CLI/JSignalHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7cb8655

Please sign in to comment.