EXC_BREAKPOINT (SIGTRAP) on Mac arm64?

I received a crash dump from an ARM64 Mac. I see my code here but from what I can tell it looks like this "crash" occurred during cleanup/quit.

One thing that caught my eye here is the symbol __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ that shows up just before exit. Does this mean the watchdog timeout initiated exit? Can I determine why?

Crashed Thread:        13

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x000000019c61427c

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [60432]

...


Thread 13 Crashed:
0   FrontBoardServices                  0x000000019c61427c -[FBSMainRunLoopSerialQueue assertBarrierOnQueue] + 144 (FBSSerialQueue.m:264)
1   FrontBoardServices                  0x000000019c5ca91c -[FBSScene detachLayer:] + 44 (FBSScene.m:222)
2   UIKitCore                           0x00000001b59c0538 -[_UIFBSSceneSubstrate detachContext:] + 92 (_UIFBSSceneSubstrate.m:74)
3   UIKitCore                           0x00000001b5569168 __UIContextBinderDetachContext + 240 (_UIContextBinder.m:367)
4   UIKitCore                           0x00000001b5569014 -[_UIContextBinder detachBindable:] + 192 (_UIContextBinder.m:149)
5   UIKitCore                           0x00000001b5568ed0 -[UIWindowScene _windowUpdatedVisibility:] + 84 (UIWindowScene.m:1162)
6   UIKitCore                           0x00000001b5568d38 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 192 (UIWindow.m:2330)
7   UIKitCore                           0x00000001b55b9ae8 -[UIWindow _setHidden:forced:] + 104 (UIWindow.m:2556)
8   SDL2                                0x00000001026ccb6c 0x102660000 + 445292
9   SDL2                                0x0000000102713828 SDL_DestroyWindow + 164
10  My App                              0x0000000102073890 cleanup + 60 (init.c:129)
11  libsystem_c.dylib                   0x0000000186ddcfa8 __cxa_finalize_ranges + 492 (atexit.c:292)
12  libsystem_c.dylib                   0x0000000186ddcd20 exit + 44 (exit.c:78)
13  UIKitMacHelper                      0x000000019fbb60ec __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ + 192 (UINSLifecycleWatchdog.m:35)
14  UIKitMacHelper                      0x000000019fbb487c __60-[UINSLifecycleWatchdog initWithStateIdentifier:andTimeout:]_block_invoke + 1160 (UINSLifecycleWatchdog.m:77)
15  UIKitMacHelper                      0x000000019fbb5828 run_watchdog_thread + 276 (UINSLifecycleWatchdog.m:305)
16  libsystem_pthread.dylib             0x0000000186f1d034 _pthread_start + 136 (pthread.c:904)
17  libsystem_pthread.dylib             0x0000000186f17e3c thread_start + 8 (:-1)

There are a couple of issues here to untangle:

First is why the watchdog was triggered. It's possible that your application's main thread became blocked. We would need to see the full crash report to tell.

Second is why the application crashed during watchdog-induced exit. The answer can be found in here in your backtrace:

7   UIKitCore                           0x00000001b55b9ae8 -[UIWindow _setHidden:forced:] + 104 (UIWindow.m:2556)
8   SDL2                                0x00000001026ccb6c 0x102660000 + 445292
9   SDL2                                0x0000000102713828 SDL_DestroyWindow + 164
10  My App                              0x0000000102073890 cleanup + 60 (init.c:129)
11  libsystem_c.dylib                   0x0000000186ddcfa8 __cxa_finalize_ranges + 492 (atexit.c:292)
12  libsystem_c.dylib                   0x0000000186ddcd20 exit + 44 (exit.c:78)

Your code previously registered an atexit() handler. Your handler is calling SDL functions which are attempting to manipulate UIKit state. However UIKit state may only be manipulated from the main thread (unless specific APIs are documented otherwise). Handlers registered with atexit() are invoked on the thread that calls exit, which in this case was not the main thread.

EXC_BREAKPOINT (SIGTRAP) on Mac arm64?
 
 
Q