1
0
mirror of synced 2024-09-24 11:38:26 +02:00

fix: Infinite loop on crash

This commit is contained in:
WerWolv 2023-12-20 13:38:13 +01:00
parent 1ea8269dec
commit bf6b2db0cb
2 changed files with 9 additions and 19 deletions

View File

@ -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);

View File

@ -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))) {