1 /* TEST_CONFIG OS=macosx
5 objc\[\d+\]: objc_removeExceptionHandler\(\) called with unknown alt handler; this is probably a bug in multithreaded AppKit use. Set environment variable OBJC_DEBUG_ALT_HANDLERS=YES or break in objc_alt_handler_error\(\) to debug.
6 objc\[\d+\]: objc_removeExceptionHandler\(\) called with unknown alt handler; this is probably a bug in multithreaded AppKit use.
13 #include <objc/objc-exception.h>
17 Mail installs an alt handler on one thread and deletes it on another.
18 This confuses the alt handler machinery, which halts the process.
23 void handler(id unused __unused, void *context __unused)
29 #if __clang__ && __cplusplus
30 // alt handlers need the objc personality
31 // catch (id) workaround forces the objc personality
33 testwarn("rdar://9183014 clang uses wrong exception personality");
34 } @catch (id e __unused) {
39 // Install 4 alt handlers
40 uintptr_t t1, t2, t3, t4;
41 t1 = objc_addExceptionHandler(&handler, NULL);
42 t2 = objc_addExceptionHandler(&handler, NULL);
43 t3 = objc_addExceptionHandler(&handler, NULL);
44 t4 = objc_addExceptionHandler(&handler, NULL);
47 objc_removeExceptionHandler(t1);
48 objc_removeExceptionHandler(t2);
49 objc_removeExceptionHandler(t3);
51 // Create an alt handler on another thread
52 // that collides with one of the removed handlers
55 Token = objc_addExceptionHandler(&handler, NULL);
60 // Incorrectly remove the other thread's handler
61 objc_removeExceptionHandler(Token);
62 // Remove the 4th handler
63 objc_removeExceptionHandler(t4);
65 // Install 8 more handlers.
66 // If the other thread's handler was not ignored,
68 objc_addExceptionHandler(&handler, NULL);
69 objc_addExceptionHandler(&handler, NULL);
70 objc_addExceptionHandler(&handler, NULL);
71 objc_addExceptionHandler(&handler, NULL);
72 objc_addExceptionHandler(&handler, NULL);
73 objc_addExceptionHandler(&handler, NULL);
74 objc_addExceptionHandler(&handler, NULL);
75 objc_addExceptionHandler(&handler, NULL);
79 // This should have crashed earlier.