From d96cac12825c79f6909bd5c4a750250314570f74 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 31 Jan 2012 17:15:14 +0000 Subject: [PATCH] Found and fixed bug in personality function: Don't dive into the action table if the action entry is zero. llvm-svn: 149389 --- libcxxabi/src/cxa_personality.cpp | 8 ++++++-- libcxxabi/src/temporary.cpp | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index 1b6f1c42ee72..fa9ed28b2af8 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -519,8 +519,7 @@ scan_eh_tab(scan_results& results, _Unwind_Action actions, bool native_exception if (actionEntry == 0) { // Found a cleanup - // If this is a type 1 or type 2 search, ignore the clean up - // and continue to scan for a handler. + // If this is a type 1 or type 2 search, there are no handlers // If this is a type 3 search, you want to install the cleanup. if ((actions & _UA_CLEANUP_PHASE) && !(actions & _UA_HANDLER_FRAME)) { @@ -529,6 +528,9 @@ scan_eh_tab(scan_results& results, _Unwind_Action actions, bool native_exception results.reason = _URC_HANDLER_FOUND; return; } + // No handler here + results.reason = _URC_CONTINUE_UNWIND; + return; } // Convert 1-based byte offset into const uint8_t* action = actionTableStart + (actionEntry - 1); @@ -814,7 +816,9 @@ __gxx_personality_v0(int version, _Unwind_Action actions, uint64_t exceptionClas results.adjustedPtr = exception_header->adjustedPtr; } else + { scan_eh_tab(results, actions, native_exception, unwind_exception, context); + } _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), (uintptr_t)unwind_exception); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), results.ttypeIndex); _Unwind_SetIP(context, results.landingPad); diff --git a/libcxxabi/src/temporary.cpp b/libcxxabi/src/temporary.cpp index 76f6b9133979..5facf39de26a 100644 --- a/libcxxabi/src/temporary.cpp +++ b/libcxxabi/src/temporary.cpp @@ -15,14 +15,26 @@ extern "C" { static -void f() +void f1() { - abort_message("this shouldn't be called"); + abort_message("__cxa_new_handler shouldn't be called"); } -void (*__cxa_new_handler)() = f; -void (*__cxa_terminate_handler)() = f; -void (*__cxa_unexpected_handler)() = f; +static +void f2() +{ + abort_message("__cxa_terminate_handler shouldn't be called"); +} + +static +void f3() +{ + abort_message("__cxa_unexpected_handler shouldn't be called"); +} + +void (*__cxa_new_handler)() = f1; +void (*__cxa_terminate_handler)() = f2; +void (*__cxa_unexpected_handler)() = f3; }