Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bug in ObjC++ EH.
Throwing an Objective-C exception through a C++ catch block was broken.
This was because the C++ code inserts a cleanup handler to make sure
that it invokes `__cxa_end_catch`.  Unwinding through this catchup
transformed the Objective-C exception into a C++ one.  This case should
have been handled, except for two bugs:

1. A typo (`#ifdef` instead of `#ifndef`) meant that we were not
   extracting the Objective-C exception from the C++ object.
2. We were skipping everything except catchalls after the search phase,
   because we lose some information in the transformation.

Fixes #49
  • Loading branch information
davidchisnall committed Dec 25, 2017
1 parent f670951 commit 7bd78e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eh_personality.c
Expand Up @@ -330,7 +330,7 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version,
// The object to return
void *object = NULL;

#ifdef NO_OBJCXX
#ifndef NO_OBJCXX
if (exceptionClass == cxx_exception_class)
{
int objcxx;
Expand Down Expand Up @@ -421,7 +421,7 @@ static inline _Unwind_Reason_Code internal_objc_personality(int version,
// If this is not a cleanup, ignore it and keep unwinding.
//if (check_action_record(context, foreignException, &lsda,
//action.action_record, thrown_class, &selector) != handler_cleanup)
if (handler != handler_cleanup)
if ((handler != handler_cleanup) && !objcxxException)
{
DEBUG_LOG("Ignoring handler! %d\n",handler);
return continueUnwinding(exceptionObject, context);
Expand Down

0 comments on commit 7bd78e5

Please sign in to comment.