From 2e86a5f9290bc6b90786dff489657b0764e6d888 Mon Sep 17 00:00:00 2001 From: Ibrahn Sahir Date: Mon, 24 Sep 2018 22:21:05 +0100 Subject: [PATCH] Fixed hang when segfaulting after OS object destroyed (OSX and X11) The two POSIX style crash handlers (OSX and X11) now remove their signal handlers when they are destroyed. Additonally if they are called while no OS singleton is set, they will simply abort(). This should not happen now that they remove themselves, but if a future change seperates OS object and crash handler lifetimes, this may be easier to report/debug than hanging on SIGSEGV. (cherry picked from commit 653b8324223414002e198eb2a8a685903186b97e) --- platform/osx/crash_handler_osx.mm | 6 ++++-- platform/x11/crash_handler_x11.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm index 3dcf8b62b2f..46efca6ef88 100644 --- a/platform/osx/crash_handler_osx.mm +++ b/platform/osx/crash_handler_osx.mm @@ -74,8 +74,9 @@ static uint32_t load_address() { } static void handle_crash(int sig) { - if (OS::get_singleton() == NULL) - return; + if (OS::get_singleton() == NULL) { + abort(); + } void *bt_buffer[256]; size_t size = backtrace(bt_buffer, 256); @@ -157,6 +158,7 @@ CrashHandler::CrashHandler() { } CrashHandler::~CrashHandler() { + disable(); } void CrashHandler::disable() { diff --git a/platform/x11/crash_handler_x11.cpp b/platform/x11/crash_handler_x11.cpp index e89468ec45d..9680f744a4b 100644 --- a/platform/x11/crash_handler_x11.cpp +++ b/platform/x11/crash_handler_x11.cpp @@ -45,8 +45,9 @@ #include static void handle_crash(int sig) { - if (OS::get_singleton() == NULL) - return; + if (OS::get_singleton() == NULL) { + abort(); + } void *bt_buffer[256]; size_t size = backtrace(bt_buffer, 256); @@ -115,6 +116,7 @@ CrashHandler::CrashHandler() { } CrashHandler::~CrashHandler() { + disable(); } void CrashHandler::disable() {