MCPcopy Create free account
hub / github.com/Niko1221/Strata / stall_stack_handler

Function stall_stack_handler

engine/src/kernels/cpu/pool.cpp:49–56  ·  view source on GitHub ↗

The stall report (issue #29, #35) can show where every pool thread is: each one is sent SIGUSR2, and its handler writes its own call stack ("module(+offset) [address]", what addr2line -e +offset reads) to stderr. Not async-signal-safe in theory, and it runs once, just before the abort of a process that is already lost.

Source from the content-addressed store, hash-verified

47// The stall report (issue #29, #35) can show where every pool thread is: each one is sent SIGUSR2, and its handler writes its own call stack ("module(+offset) [address]", what
48// addr2line -e <module> +offset reads) to stderr. Not async-signal-safe in theory, and it runs once, just before the abort of a process that is already lost.
49void stall_stack_handler(int) {
50 void* frames[24];
51 const int n = backtrace(frames, 24);
52 char head[64];
53 const int len = std::snprintf(head, sizeof head, " stack of thread %ld:\n", (long) syscall(SYS_gettid));
54 if (len > 0) { const ssize_t w = write(2, head, (size_t) len); (void) w; }
55 backtrace_symbols_fd(frames, n, 2);
56}
57void dump_thread_stacks(std::vector<std::thread>& threads) {
58 struct sigaction sa{};
59 sa.sa_handler = stall_stack_handler;

Callers

nothing calls this directly

Calls 1

writeFunction · 0.70

Tested by

no test coverage detected