ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
563 stars 47 forks source link

Bug in Xcode 15 beta 5? PyObjCTest.test_functions.test_function_raises crash #568

Closed ronaldoussoren closed 1 year ago

ronaldoussoren commented 1 year ago

This only happens when using Xcode 15 beta 5 and running on x86_64 (both natively and with arch -x86_64 ...).

In pyobjc-core PyObjCTest.test_functions.test_function_raises crashes due to an uncaught exception, even though the code for calling functions through libffi catches exceptions.

The following fixes the issue:

diff --git a/pyobjc-core/Modules/objc/test/metadatafunction.m b/pyobjc-core/Modules/objc/test/metadatafunction.m
index c738dc05a..1ad96ef3c 100644
--- a/pyobjc-core/Modules/objc/test/metadatafunction.m
+++ b/pyobjc-core/Modules/objc/test/metadatafunction.m
@@ -462,9 +462,9 @@
 static void
 raiseFunc(void)
 {
-    @throw [NSException exceptionWithName:@"ExceptionName"
+    [[NSException exceptionWithName:@"ExceptionName"
                                    reason:@"No Reason"
-                                 userInfo:nil];
+                                 userInfo:nil] raise];
 }

That indicates that clang somehow miscompules the original code. This happens both with "-flto -O3" and without (in pyobjc-core/setup.py CFLAGS)

Not sure yet how to reproduce this without PyObjC, although I have only tried in a single source file (without dynamic loading).

ronaldoussoren commented 1 year ago

There's also a similar problem in the vectorcall tests, again with exception processing. This time both arm64 and x86_64.

ronaldoussoren commented 1 year ago

c8269ac8cdaa6cdc5df7c3f917232bf2d73c641e contains a workaround for this to enable full test runs, should be reverted in the future...

ronaldoussoren commented 1 year ago

The issue appears to be fixed with Xcode 15 beta 6.