MCPcopy Create free account
hub / github.com/FastLED/FastLED / crash_handler

Function crash_handler

tests/crash_handler_libunwind.h:44–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44inline void crash_handler(int sig) {
45 // Prevent recursion if handler crashes
46 static volatile sig_atomic_t already_dumping = 0;
47 if (already_dumping) {
48 // Recursive crash - bail out immediately
49 signal(sig, SIG_DFL);
50 raise(sig);
51 return;
52 }
53 already_dumping = 1;
54
55 fprintf(stderr, "\n=== INTERNAL CRASH HANDLER (SIGNAL %d) ===\n", sig);
56
57 // Internal stack trace dump
58 print_stacktrace_libunwind();
59
60 fprintf(stderr, "=== END INTERNAL HANDLER ===\n\n");
61 fflush(stdout);
62 fflush(stderr);
63
64 // CHAINING: Uninstall our handler and re-raise signal
65 // This allows external debuggers to catch the signal
66 fprintf(stderr, "Uninstalling crash handler and re-raising signal %d for external debugger...\n", sig);
67 fflush(stderr);
68
69 // Restore default handler
70 signal(sig, SIG_DFL);
71
72 // Re-raise the signal - will now go to default handler or external debugger
73 raise(sig);
74
75 // If we get here, signal didn't terminate us - exit manually
76 exit(1);
77}
78
79inline void setup_crash_handler() {
80 // Check if crash handler should be disabled (for debugger attachment)

Callers

nothing calls this directly

Calls 3

fflushFunction · 0.85
exitFunction · 0.85

Tested by

no test coverage detected