Found and fixed bug in personality function: Don't dive into the action table if the action entry is zero.

llvm-svn: 149389
This commit is contained in:
Howard Hinnant 2012-01-31 17:15:14 +00:00
parent bac45f610d
commit d96cac1282
2 changed files with 23 additions and 7 deletions

View File

@ -519,8 +519,7 @@ scan_eh_tab(scan_results& results, _Unwind_Action actions, bool native_exception
if (actionEntry == 0) if (actionEntry == 0)
{ {
// Found a cleanup // Found a cleanup
// If this is a type 1 or type 2 search, ignore the clean up // If this is a type 1 or type 2 search, there are no handlers
// and continue to scan for a handler.
// If this is a type 3 search, you want to install the cleanup. // If this is a type 3 search, you want to install the cleanup.
if ((actions & _UA_CLEANUP_PHASE) && !(actions & _UA_HANDLER_FRAME)) 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; results.reason = _URC_HANDLER_FOUND;
return; return;
} }
// No handler here
results.reason = _URC_CONTINUE_UNWIND;
return;
} }
// Convert 1-based byte offset into // Convert 1-based byte offset into
const uint8_t* action = actionTableStart + (actionEntry - 1); 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; results.adjustedPtr = exception_header->adjustedPtr;
} }
else else
{
scan_eh_tab(results, actions, native_exception, unwind_exception, context); 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(0), (uintptr_t)unwind_exception);
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), results.ttypeIndex); _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), results.ttypeIndex);
_Unwind_SetIP(context, results.landingPad); _Unwind_SetIP(context, results.landingPad);

View File

@ -15,14 +15,26 @@ extern "C"
{ {
static 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; static
void (*__cxa_terminate_handler)() = f; void f2()
void (*__cxa_unexpected_handler)() = f; {
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;
} }