Skip to content

Commit

Permalink
LIBS: merged msvc fix for backward
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Sep 16, 2024
1 parent 93ece77 commit b4478fc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion contrib/libs/backward/backward.h
Original file line number Diff line number Diff line change
Expand Up @@ -4342,7 +4342,7 @@ class SignalHandling {
}
cv().notify_one();
}) {
SetUnhandledExceptionFilter(crash_handler);
*prev_exception_filter_ptr() = SetUnhandledExceptionFilter(crash_handler);

signal(SIGABRT, signal_handler);
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
Expand Down Expand Up @@ -4378,6 +4378,11 @@ class SignalHandling {
return &data;
}

static LPTOP_LEVEL_EXCEPTION_FILTER *prev_exception_filter_ptr() {
static LPTOP_LEVEL_EXCEPTION_FILTER prev_exception_filter;
return &prev_exception_filter;
}

enum class crash_status { running, crashed, normal_exit, ending };

static crash_status &crashed() {
Expand Down Expand Up @@ -4441,6 +4446,11 @@ class SignalHandling {
}

NOINLINE static LONG WINAPI crash_handler(EXCEPTION_POINTERS *info) {
// Pass-through MSVC exceptions
if ((*prev_exception_filter_ptr()) != nullptr &&
info->ExceptionRecord->ExceptionCode == 0xE06D7363) {
return (*prev_exception_filter_ptr())(info);
}
// The exception info supplies a trace from exactly where the issue was,
// no need to skip records
crash_handler(0, info->ContextRecord);
Expand Down

0 comments on commit b4478fc

Please sign in to comment.