From 1be67aa8295314fb794c4e933d9bb7c7c33e0ca4 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 25 Nov 2011 15:37:14 +0000 Subject: Tweak the cleanup code slightly. --- src/exception.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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; } -- cgit v1.2.3