diff options
author | dim <dim@FreeBSD.org> | 2016-05-05 22:40:07 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-05-05 22:40:07 +0000 |
commit | cd441cb611883539e14becffc6ba847cf6b24f7a (patch) | |
tree | 981aba4368a927bfed005088ee808eae8f51272b /contrib/libcxxrt/exception.cc | |
parent | 68d7e14c1b8fc2f6a8c21ef0402dff5f42ae129b (diff) | |
download | FreeBSD-src-cd441cb611883539e14becffc6ba847cf6b24f7a.zip FreeBSD-src-cd441cb611883539e14becffc6ba847cf6b24f7a.tar.gz |
Import libcxxrt master 516a65c109eb0a01e5e95fbef455eb3215135cef.
Interesting fixes:
3adaa2e Fix _Unwind_Exception cleanup functions
286776c Check exception cleanup function ptr before calling
edda626 Correct exception specifications on new and delete operators
Diffstat (limited to 'contrib/libcxxrt/exception.cc')
-rw-r--r-- | contrib/libcxxrt/exception.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/contrib/libcxxrt/exception.cc b/contrib/libcxxrt/exception.cc index 052541f..84fc92d 100644 --- a/contrib/libcxxrt/exception.cc +++ b/contrib/libcxxrt/exception.cc @@ -304,13 +304,17 @@ static pthread_key_t eh_key; static void exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_exception(static_cast<void*>(ex)); + // Exception layout: + // [__cxa_exception [_Unwind_Exception]] [exception object] + // + // __cxa_free_exception expects a pointer to the exception object + __cxa_free_exception(static_cast<void*>(ex + 1)); } static void dependent_exception_cleanup(_Unwind_Reason_Code reason, struct _Unwind_Exception *ex) { - __cxa_free_dependent_exception(static_cast<void*>(ex)); + __cxa_free_dependent_exception(static_cast<void*>(ex + 1)); } /** @@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_info) if (info->foreign_exception_state != __cxa_thread_info::none) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } else { @@ -1282,12 +1287,13 @@ extern "C" void __cxa_end_catch() if (ti->foreign_exception_state != __cxa_thread_info::none) { - globals->caughtExceptions = 0; if (ti->foreign_exception_state != __cxa_thread_info::rethrown) { _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); - e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); + if (e->exception_cleanup) + e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); } + globals->caughtExceptions = 0; ti->foreign_exception_state = __cxa_thread_info::none; return; } |