diff options
author | Howard Hinnant <hhinnant@apple.com> | 2012-01-31 01:51:15 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2012-01-31 01:51:15 +0000 |
commit | 1a58491066c80bd4b599e49fe0930b9390807e0b (patch) | |
tree | 3fade49d0178abc8120b0def33f01d8c5ce9db39 /src/cxa_handlers.cpp | |
parent | 4c8d5613f35b03a3b6dc050a822e9a63e038e837 (diff) |
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
Diffstat (limited to 'src/cxa_handlers.cpp')
-rw-r--r-- | src/cxa_handlers.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
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()); } |