diff options
author | David Chisnall <dchisnall@pathscale.com> | 2011-11-25 15:37:14 +0000 |
---|---|---|
committer | David Chisnall <dchisnall@pathscale.com> | 2011-11-25 15:37:14 +0000 |
commit | 1be67aa8295314fb794c4e933d9bb7c7c33e0ca4 (patch) | |
tree | 1a661c57829c9e319bc6d51bad4ba944b31103d8 /src | |
parent | c1e126a45fd8610347d428bea3dbf038a83002db (diff) | |
download | libcxxrt-1be67aa8295314fb794c4e933d9bb7c7c33e0ca4.tar.gz libcxxrt-1be67aa8295314fb794c4e933d9bb7c7c33e0ca4.tar.bz2 libcxxrt-1be67aa8295314fb794c4e933d9bb7c7c33e0ca4.tar.xz |
Tweak the cleanup code slightly.
Diffstat (limited to 'src')
-rw-r--r-- | src/exception.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/exception.cc b/src/exception.cc index d53d997..abf6a10 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -953,6 +953,12 @@ static void pushCleanupException(_Unwind_Exception *exceptionObject, __cxa_thread_info *info = thread_info_fast(); if (ex) { + ex->cleanupCount++; + if (ex->cleanupCount > 1) + { + assert(exceptionObject == info->currentCleanup); + return; + } ex->nextCleanup = info->currentCleanup; } info->currentCleanup = exceptionObject; @@ -1386,7 +1392,16 @@ extern "C" _Unwind_Exception *__cxa_get_cleanup(void) if (isCXXException(exceptionObject->exception_class)) { __cxa_exception *ex = exceptionFromPointer(exceptionObject); - info->currentCleanup = ex->nextCleanup; + ex->cleanupCount--; + if (ex->cleanupCount == 0) + { + info->currentCleanup = ex->nextCleanup; + ex->nextCleanup = 0; + } + } + else + { + info->currentCleanup = 0; } return exceptionObject; } |