fix: Infinite loop on crash
This commit is contained in:
parent
1ea8269dec
commit
bf6b2db0cb
@ -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
|
// 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(DEBUG)
|
||||||
|
|
||||||
|
static bool breakpointTriggered = false;
|
||||||
|
if (!breakpointTriggered) {
|
||||||
|
breakpointTriggered = true;
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
#else
|
#else
|
||||||
raise(SIGTRAP);
|
raise(SIGTRAP);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
std::exit(signalNumber);
|
std::exit(signalNumber);
|
||||||
|
|
||||||
|
@ -316,20 +316,6 @@ namespace hex {
|
|||||||
g_oldWndProc = ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)commonWindowProc);
|
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
|
// Set up a taskbar progress handler
|
||||||
{
|
{
|
||||||
if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {
|
if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user