From b4478fc54709d167cac0dd507cc2987175537dff Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Tue, 30 Jul 2024 20:44:51 +0200 Subject: [PATCH] LIBS: merged msvc fix for backward see https://github.com/bombela/backward-cpp/pull/336 --- contrib/libs/backward/backward.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/libs/backward/backward.h b/contrib/libs/backward/backward.h index 3fb49f0958..32cde951ad 100644 --- a/contrib/libs/backward/backward.h +++ b/contrib/libs/backward/backward.h @@ -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); @@ -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() { @@ -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);