From 308f1e249b178c394509341ba7ab49fc98b9c824 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 28 Mar 2026 20:14:58 -0700 Subject: [PATCH] crash: unmask signals before reexec Signals were previously left masked before reexec, causing UB if a child were to crash again, instead of triggering the reporter. This might've been responsible for a number of unexplainable bugs. --- src/crash/handler.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/crash/handler.cpp b/src/crash/handler.cpp index 8f37085..045a148 100644 --- a/src/crash/handler.cpp +++ b/src/crash/handler.cpp @@ -58,6 +58,12 @@ void signalHandler( siginfo_t* /*info*/, // NOLINT (misc-include-cleaner) void* /*context*/ ) { + // NOLINTBEGIN (misc-include-cleaner) + sigset_t set; + sigfillset(&set); + sigprocmask(SIG_UNBLOCK, &set, nullptr); + // NOLINTEND + if (CrashInfo::INSTANCE.traceFd != -1) { auto traceBuffer = std::array(); auto frameCount = cpptrace::safe_generate_raw_trace(traceBuffer.data(), traceBuffer.size(), 1); @@ -79,13 +85,9 @@ void signalHandler( fail:; } + // TODO: coredump fork and crash reporter remain as zombies, fix auto coredumpPid = fork(); if (coredumpPid == 0) { - // NOLINTBEGIN (misc-include-cleaner) - sigset_t set; - sigfillset(&set); - sigprocmask(SIG_UNBLOCK, &set, nullptr); - // NOLINTEND raise(sig); _exit(-1); } @@ -131,7 +133,6 @@ void signalHandler( perror("Failed to fork and launch crash reporter.\n"); _exit(-1); } else if (pid == 0) { - // dup to remove CLOEXEC auto dumpFdStr = std::array(); auto logFdStr = std::array();