Skip to content

Commit 634fac4

Browse files
committed
CrashHandler: Fix recursive backtrace on Linux
1 parent 2b18df0 commit 634fac4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/common/assert.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ extern "C" __attribute__((weak)) void android_set_abort_message(const char*);
8282
{
8383
#ifndef __ANDROID__
8484
std::fputs(szMsg, stderr);
85-
CrashHandler::WriteDumpForCaller(szMsg);
86-
std::fputs("Aborting application.\n", stderr);
8785
std::fflush(stderr);
8886
std::abort();
8987
#else

src/common/crash_handler.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ const char* CrashHandler::GetSignalName(int signal_no)
285285
// clang-format off
286286
case SIGSEGV: return "SIGSEGV";
287287
case SIGBUS: return "SIGBUS";
288+
case SIGABRT: return "SIGABRT";
288289
default: return "UNKNOWN";
289290
// clang-format on
290291
}
@@ -391,9 +392,13 @@ void CrashHandler::CrashSignalHandler(int signal, siginfo_t* siginfo, void* ctx)
391392
lock.unlock();
392393

393394
// We can't continue from here. Just bail out and dump core.
394-
std::fputs("Aborting application.\n", stderr);
395-
std::fflush(stderr);
396-
std::abort();
395+
static const char abort_message[] = "Aborting application.\n";
396+
write(STDERR_FILENO, abort_message, sizeof(abort_message) - 1);
397+
398+
// Call default abort signal handler, regardless of whether this was SIGSEGV or SIGABRT.
399+
lock.lock();
400+
std::signal(SIGABRT, SIG_DFL);
401+
raise(SIGABRT);
397402
}
398403

399404
bool CrashHandler::Install(CleanupHandler cleanup_handler)
@@ -412,8 +417,6 @@ bool CrashHandler::Install(CleanupHandler cleanup_handler)
412417
return false;
413418
if (sigaction(SIGSEGV, &sa, nullptr) != 0)
414419
return false;
415-
416-
sa.sa_flags = SA_SIGINFO;
417420
if (sigaction(SIGABRT, &sa, nullptr) != 0)
418421
return false;
419422

0 commit comments

Comments
 (0)