Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass MSVC exception through SetUnhandledExceptionFilter #336

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4333,8 +4333,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 @@ -4364,6 +4363,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 @@ -4427,6 +4431,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