From 1a58491066c80bd4b599e49fe0930b9390807e0b Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 31 Jan 2012 01:51:15 +0000 Subject: Minor bug fix in __cxa_call_unexpected. Changed std::terminate to detect a caught-but-unhandled exception, and choose the handler out of that if found. git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@149329 91177308-0d34-0410-b5e6-96231b3b80d8 --- src/cxa_handlers.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/cxa_handlers.cpp') diff --git a/src/cxa_handlers.cpp b/src/cxa_handlers.cpp index 98f7c25..93cc269 100644 --- a/src/cxa_handlers.cpp +++ b/src/cxa_handlers.cpp @@ -150,6 +150,25 @@ __attribute__((noreturn)) void terminate() _NOEXCEPT { + // If there might be an uncaught exception + using namespace __cxxabiv1; + __cxa_eh_globals* globals = __cxa_get_globals_fast(); + if (globals) + { + __cxa_exception* exception_header = globals->caughtExceptions; + if (exception_header) + { + _Unwind_Exception* unwind_exception = + reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1; + bool native_exception = (unwind_exception->exception_class & get_language) == + (kOurExceptionClass & get_language); + if (native_exception) + { + __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1; + __terminate(exception_header->terminateHandler); + } + } + } __terminate(get_terminate()); } -- cgit v1.2.3