Skip to content

Commit bf3531d

Browse files
committed
Make crash reports reliable in multithreaded case
1 parent 3b0ea2d commit bf3531d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

libc/log/oncrash_amd64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ void ShowCrashReportHook(int, int, int, struct siginfo *, ucontext_t *);
192192

193193
static relegated void ShowCrashReport(int err, int sig, struct siginfo *si,
194194
ucontext_t *ctx) {
195+
if (sig != SIGTRAP && sig != SIGQUIT)
196+
sigaddset(&ctx->uc_sigmask, sig);
195197
#pragma GCC push_options
196198
#pragma GCC diagnostic ignored "-Walloca-larger-than="
197199
long size = __get_safe_size(8192, 4096);

libc/log/oncrash_arm64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ static relegated char *GetSymbolName(struct SymbolTable *st, int symbol) {
191191

192192
static relegated void __oncrash_impl(int sig, struct siginfo *si,
193193
ucontext_t *ctx) {
194+
if (sig != SIGTRAP && sig != SIGQUIT)
195+
sigaddset(&ctx->uc_sigmask, sig);
194196
#pragma GCC push_options
195197
#pragma GCC diagnostic ignored "-Walloca-larger-than="
196198
long size = __get_safe_size(10000, 4096);

libc/log/showcrashreports.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ void ShowCrashReports(void) {
8585
#ifdef __x86_64__
8686
InstallCrashHandler(SIGTRAP, 0);
8787
#else
88-
InstallCrashHandler(SIGTRAP, SA_RESETHAND);
88+
InstallCrashHandler(SIGTRAP, 0);
8989
#endif
90-
InstallCrashHandler(SIGFPE, SA_RESETHAND);
91-
InstallCrashHandler(SIGILL, SA_RESETHAND);
92-
InstallCrashHandler(SIGBUS, SA_RESETHAND);
93-
InstallCrashHandler(SIGABRT, SA_RESETHAND);
94-
InstallCrashHandler(SIGSEGV, SA_RESETHAND | SA_ONSTACK);
90+
InstallCrashHandler(SIGFPE, 0);
91+
InstallCrashHandler(SIGILL, 0);
92+
InstallCrashHandler(SIGBUS, 0);
93+
InstallCrashHandler(SIGABRT, 0);
94+
InstallCrashHandler(SIGSEGV, SA_ONSTACK);
9595
}
9696

9797
IGNORE_LEAKS(ShowCrashReports)

0 commit comments

Comments
 (0)