I have very strange crash with OpenURL on iOS 9.3.x. The pipeline is the following:
- on applicationDidBecomeActive i call the method, which calls method on different thread
- on those thread i call openURL:
- Application crashes after call to objc_sync_enter (there is no call to objc_sync_exit, so it seems thread is locked).
Crash logs for main thread:
0 libsystem_kernel.dylib 0x0000000181c83f6c __psynch_mutexwait + 8
1 libsystem_pthread.dylib 0x0000000181d5239c _pthread_mutex_lock_wait + 96
2 libsystem_pthread.dylib 0x0000000181d5257c _pthread_mutex_lock_slow + 296
3 libobjc.A.dylib 0x000000018175b780 recursive_mutex_tt<false>::lock() + 16
4 libobjc.A.dylib 0x000000018175e110 objc_sync_enter + 28
5 App 0x00000001001ef7c4 -[TouchIDLoginManager isShowingTouchId] + 20
6 App 0x000000010019c0c0 +[UIApplicationDelegate applicationDidBecomeActive:] + 64
7 App 0x000000010019aa14 -[NSObject(UIApplicationDelegate) p_ApplicationDidBecomeActive:] + 64
the stack from the thread, where i call openURL:
Thread 17 name: Dispatch queue: la_client
Thread 17:
0 libsystem_kernel.dylib 0x0000000181c69014 semaphore_wait_trap + 8
1 libdispatch.dylib 0x0000000181b463e8 _dispatch_semaphore_wait_slow + 244
2 libxpc.dylib 0x0000000181d82620 xpc_connection_send_message_with_reply_sync + 204
3 MobileCoreServices 0x000000018391214c _LSStartOpenOperation + 232
4 MobileCoreServices 0x0000000183939e18 -[LSOpenOperation main] + 1160
5 MobileCoreServices 0x0000000183919ad4 -[LSApplicationWorkspace openURL:withOptions:error:] + 472
6 UIKit 0x00000001874f0ec8 -[UIApplication _openURL:] + 356
7 AppKinetics-SaveEditClient 0x00000001001ebda0 -[UIApplication(some_category) openURLReplacement:] + 500
So, there is categories, which replaces openURL, but there is only call to openURL in some specific call. I've found the solution to use different queue to call openURL, but in my case it has already called on different thread.
the common reason:
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Exception Note: SIMULATED (this is NOT a crash)
Highlighted by Thread: 17
So, app was killed by OS. issue is not reproducible under Xcode debug, and reproduces only occasionally.
Does absence of objc_sync_enter
means deadlock on main thread? My question is about roots of deadlock, I know, what 0x000000008badf00d code means
Does anybody know the workaround for this case?
What is the roots of this problem?
Thanks in advance.