diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-17 10:09:21 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-17 09:50:37 +0000 |
| commit | 0e62b4321a0f7200d361ef69a36ed14fb40e10de (patch) | |
| tree | 85bb4b270c0daff988e78c640ea0f880ad83676f /executor/executor_runner.h | |
| parent | 3e908871f2a4ad7e80057fb82b2fc7cb34f74dcb (diff) | |
executor: print signal info for SIGILL/SIGFPE as well
There are also synchnous fatal signals that can happen due to bugs
in executor code. So handle them as SIGSEGV.
Diffstat (limited to 'executor/executor_runner.h')
| -rw-r--r-- | executor/executor_runner.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/executor/executor_runner.h b/executor/executor_runner.h index 3481c052f..260d4a5de 100644 --- a/executor/executor_runner.h +++ b/executor/executor_runner.h @@ -727,7 +727,7 @@ static void SigchldHandler(int sig) // We need just blocking syscall preemption. } -static void SigsegvHandler(int sig, siginfo_t* info, void* ucontext) +static void FatalHandler(int sig, siginfo_t* info, void* ucontext) { // Print minimal debugging info we can extract reasonably easy. uintptr_t pc = 0xdeadbeef; @@ -740,11 +740,26 @@ static void SigsegvHandler(int sig, siginfo_t* info, void* ucontext) pc = mctx.pc; #endif #endif + const char* name = "unknown signal"; + switch (sig) { + case SIGSEGV: + name = "SIGSEGV"; + break; + case SIGBUS: + name = "SIGBUS"; + break; + case SIGILL: + name = "SIGILL"; + break; + case SIGFPE: + name = "SIGFPE"; + break; + } // Print the current function PC so that it's possible to map the failing PC // to a symbol in the binary offline (we usually compile as PIE). - failmsg(sig == SIGSEGV ? "SIGSEGV" : "SIGBUS", "handler:0x%zx pc:%p addr:%p", - reinterpret_cast<uintptr_t>(reinterpret_cast<void*>(SigsegvHandler)) - pc, - reinterpret_cast<void*>(pc), info->si_addr); + failmsg(name, "pc-offset:0x%zx pc:%p addr:%p code=%d", + reinterpret_cast<uintptr_t>(reinterpret_cast<void*>(FatalHandler)) - pc, + reinterpret_cast<void*>(pc), info->si_addr, info->si_code); } static void runner(char** argv, int argc) @@ -774,11 +789,11 @@ static void runner(char** argv, int argc) fail("signal(SIGCHLD) failed"); struct sigaction act = {}; act.sa_flags = SA_SIGINFO; - act.sa_sigaction = SigsegvHandler; - if (sigaction(SIGSEGV, &act, nullptr)) - fail("signal(SIGSEGV) failed"); - if (sigaction(SIGBUS, &act, nullptr)) - fail("signal(SIGBUS) failed"); + act.sa_sigaction = FatalHandler; + for (auto sig : {SIGSEGV, SIGBUS, SIGILL, SIGFPE}) { + if (sigaction(sig, &act, nullptr)) + failmsg("sigaction failed", "sig=%d", sig); + } Connection conn(manager_addr, manager_port); |
