core: Let's try getting crash callstacks on win32 with a vectored exception handler.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled

This commit is contained in:
Cory McWilliams 2025-01-02 08:32:18 -05:00
parent 54df862998
commit a3b76cd5c2

View File

@ -1008,6 +1008,23 @@ static void _error_handler(int sig)
_exit(1);
}
#if defined(_WIN32)
static LONG WINAPI _win32_exception_handler(EXCEPTION_POINTERS* info)
{
if (info->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION ||
info->ExceptionRecord->ExceptionCode == STATUS_ILLEGAL_INSTRUCTION ||
info->ExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW ||
info->ExceptionRecord->ExceptionCode == STATUS_HEAP_CORRUPTION)
{
const char* stack = tf_util_backtrace_string();
tf_printf("ERROR:\n%s\n", stack);
tf_free((void*)stack);
_exit(1);
}
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
static void _startup(int argc, char* argv[])
{
char buffer[8] = { 0 };
@ -1055,6 +1072,10 @@ static void _startup(int argc, char* argv[])
perror("signal");
}
}
#if defined(_WIN32)
AddVectoredExceptionHandler(0, _win32_exception_handler);
#endif
}
#if defined(__ANDROID__)