From bf6b2db0cb89991c43b1dddb17eeae9bb848da00 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 20 Dec 2023 13:38:13 +0100 Subject: [PATCH] fix: Infinite loop on crash --- main/gui/source/crash_handlers.cpp | 14 +++++++++----- main/gui/source/window/win_window.cpp | 14 -------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/main/gui/source/crash_handlers.cpp b/main/gui/source/crash_handlers.cpp index 769277992..bae3f1ac6 100644 --- a/main/gui/source/crash_handlers.cpp +++ b/main/gui/source/crash_handlers.cpp @@ -85,11 +85,15 @@ namespace hex::crash { // Trigger a breakpoint if we're in a debug build or raise the signal again for the default handler to handle it #if defined(DEBUG) - #if defined(OS_WINDOWS) - __debugbreak(); - #else - raise(SIGTRAP); - #endif + static bool breakpointTriggered = false; + if (!breakpointTriggered) { + breakpointTriggered = true; + #if defined(OS_WINDOWS) + __debugbreak(); + #else + raise(SIGTRAP); + #endif + } std::exit(signalNumber); diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index 4a4592eba..36f239086 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -316,20 +316,6 @@ namespace hex { g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)commonWindowProc); } - // Add a custom exception handler to detect heap corruptions - { - ::AddVectoredExceptionHandler(TRUE, [](PEXCEPTION_POINTERS exception) -> LONG { - if ((exception->ExceptionRecord->ExceptionCode & 0xF000'0000) == 0xC000'0000) { - log::fatal("Exception raised: 0x{:08X}", exception->ExceptionRecord->ExceptionCode); - if (exception->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION) { - log::fatal("Heap corruption detected!"); - } - } - - return EXCEPTION_CONTINUE_SEARCH; - }); - } - // Set up a taskbar progress handler { if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {