Fix ObjC++ interop bug.

The reworked wrapping of C++ exceptions meant that we were missing a
dereference of the result of __cxa_begin_catch.

Add a test that triggers this issue.  It would have occurred in the
non-ARC version if we actually did anything with the exception, but
compiling it in ARC mode makes the compiler insert retain / autorelease
around the exception object to ensure that it remains live.
main
David Chisnall 6 years ago committed by David Chisnall
parent 8e59872681
commit aa775cf835

@ -139,6 +139,7 @@ addtest_variants("CXXExceptions" "CXXException.m;CXXException.cc" true)
addtest_variants("ForwardDeclareProtocolAccess" "ForwardDeclareProtocolAccess.m;ForwardDeclareProtocol.m" true)
if (ENABLE_OBJCXX)
addtest_variants(ObjCXXEHInterop "ObjCXXEHInterop.mm;ObjCXXEHInterop.m" true)
addtest_variants(ObjCXXEHInterop_arc "ObjCXXEHInterop_arc.mm;ObjCXXEHInterop_arc.m" true)
endif()
# Some tests use enough memory that they fail on CI intermittently if they

@ -575,7 +575,8 @@ id objc_begin_catch(struct _Unwind_Exception *exceptionObject)
{
DEBUG_LOG("c++ catch\n");
td->current_exception_type = CXX;
return __cxa_begin_catch(exceptionObject);
id *obj = __cxa_begin_catch(exceptionObject);
return obj ? *obj : nil;
}
DEBUG_LOG("foreign exception catch\n");
// Box if we have a boxing function.

Loading…
Cancel
Save