From 9bae19198fdc7bfb71f900cfe6c1982cb2a80e4f Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 16:20:27 +0800 Subject: Revert "Fix up llexception.h's cross-platform SEH wrapper." This reverts commit 5ed8df22cd59680a685c4ada7daa5555bf59d4fe. --- indra/llcommon/llexception.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llexception.cpp') diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp index 107fdc2b2d..74b33f1e3b 100644 --- a/indra/llcommon/llexception.cpp +++ b/indra/llcommon/llexception.cpp @@ -101,36 +101,44 @@ void annotate_exception_(boost::exception& exc) static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific static constexpr U32 STATUS_STACK_FULL = 0xC00000FD; -void LL::seh::fill_stacktrace(std::string& stacktrace, U32 code) +U32 ll_seh_filter( + std::string& stacktrace, + std::function filter, + U32 code, + struct _EXCEPTION_POINTERS* exception_infop) { - // Sadly, despite its diagnostic importance, trying to capture a - // stacktrace when the stack is already blown only terminates us faster. + // By the time the handler gets control, the stack has been unwound, + // so report the stack trace now at filter() time. + // Even though stack overflow is a problem we would very much like to + // diagnose, calling another function when the stack is already blown only + // terminates us faster. if (code == STATUS_STACK_FULL) { stacktrace = "(stack overflow, no traceback)"; } else { - stacktrace = to_string(boost::stacktrace::stacktrace()); + stacktrace = boost::stacktrace::stacktrace().to_string(); } + + return filter(code, exception_infop); } -U32 LL::seh::common_filter(U32 code, struct _EXCEPTION_POINTERS*) +U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) { if (code == STATUS_MSC_EXCEPTION) { - // C++ exception, don't stop at this handler + // C++ exception, go on return EXCEPTION_CONTINUE_SEARCH; } else { // This is a non-C++ exception, e.g. hardware check. - // Pass control into the handler block. return EXCEPTION_EXECUTE_HANDLER; } } -void LL::seh::rethrow(U32 code, const std::string& stacktrace) +void seh_rethrow(U32 code, const std::string& stacktrace) { std::ostringstream out; out << "Windows exception 0x" << std::hex << code; -- cgit v1.2.3 From bbe51e86249114cac4716c391e267c499a52847a Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 3 Jun 2025 16:21:58 +0800 Subject: Revert "Promote seh_catcher() et al. to llexception.{h,cpp} for general use." This reverts commit 71d777ea126e7f02cb46c11bdb606094ca06f75c. --- indra/llcommon/llexception.cpp | 50 +++++++----------------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) (limited to 'indra/llcommon/llexception.cpp') diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp index 74b33f1e3b..c0154a569f 100644 --- a/indra/llcommon/llexception.cpp +++ b/indra/llcommon/llexception.cpp @@ -15,12 +15,7 @@ #include "llexception.h" // STL headers // std headers -#include -#include #include -#if LL_WINDOWS -#include -#endif // LL_WINDOWS // external library headers #include #include @@ -34,6 +29,7 @@ // On Windows, header-only implementation causes macro collisions -- use // prebuilt library #define BOOST_STACKTRACE_LINK +#include #endif // LL_WINDOWS #include @@ -98,34 +94,15 @@ void annotate_exception_(boost::exception& exc) // For windows SEH exception handling we sometimes need a filter that will // separate C++ exceptions from C SEH exceptions -static constexpr U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific -static constexpr U32 STATUS_STACK_FULL = 0xC00000FD; +static const U32 STATUS_MSC_EXCEPTION = 0xE06D7363; // compiler specific -U32 ll_seh_filter( - std::string& stacktrace, - std::function filter, - U32 code, - struct _EXCEPTION_POINTERS* exception_infop) +U32 msc_exception_filter(U32 code, struct _EXCEPTION_POINTERS *exception_infop) { - // By the time the handler gets control, the stack has been unwound, - // so report the stack trace now at filter() time. - // Even though stack overflow is a problem we would very much like to - // diagnose, calling another function when the stack is already blown only - // terminates us faster. - if (code == STATUS_STACK_FULL) - { - stacktrace = "(stack overflow, no traceback)"; - } - else - { - stacktrace = boost::stacktrace::stacktrace().to_string(); - } - - return filter(code, exception_infop); -} + const auto stack = to_string(boost::stacktrace::stacktrace()); + LL_WARNS() << "SEH Exception handled (that probably shouldn't be): Code " << code + << "\n Stack trace: \n" + << stack << LL_ENDL; -U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) -{ if (code == STATUS_MSC_EXCEPTION) { // C++ exception, go on @@ -133,20 +110,9 @@ U32 seh_filter(U32 code, struct _EXCEPTION_POINTERS*) } else { - // This is a non-C++ exception, e.g. hardware check. + // handle it return EXCEPTION_EXECUTE_HANDLER; } } -void seh_rethrow(U32 code, const std::string& stacktrace) -{ - std::ostringstream out; - out << "Windows exception 0x" << std::hex << code; - if (! stacktrace.empty()) - { - out << '\n' << stacktrace; - } - LLTHROW(Windows_SEH_exception(out.str())); -} - #endif //LL_WINDOWS -- cgit v1.2.3