Hi,
I get a weird deadlock in my swiftUI based application where com.apple.libtrace.state.block-list
is waiting on com.apple.main-thread
any idea what can lead to this deadlock ? also, what is com.apple.libtrace.state.block-list
used for ?
When deadlock occurs, the main thread it stucks on publishing property change that triggers callback function. for example :
# definition
@Published var event: eventType = .evtTypeWhatever
...
# setting that may linked to the deadlock :
self.handler.event = eventType.evtSomething;
# callback definition
.onReceive(cbhandler.$event, perform: eventReceived)
# implementation :
private func eventReceived(_ type:eventType) {
switch type {
case .evtSomething:
# do something
Here's the relevant callstack. We can see that It even didn’t get to the callback. The deadlock is probably in publishing mechanism itself
2480 Thread_87233850 DispatchQueue_1: com.apple.main-thread (serial)
+ 2480 start (in dyld) + 6076 [0x197c92b98]
+ 2480 __debug_main_executable_dylib_entry_point (in myAgent.debug.dylib) + 12 [0x10402fc38] myApp.swift:0
+ 2480 static networkWrapperAppApp.$main() (in myAgent.debug.dylib) + 40 [0x10402fbf8] /<compiler-generated>:0
+ 2480 static App.main() (in SwiftUI) + 224 [0x1c8b2a5c0]
+ 2480 runApp<A>(_:) (in SwiftUI) + 108 [0x1c87c9658]
+ 2480 specialized runApp(_:) (in SwiftUI) + 160 [0x1c836b878]
+ 2480 NSApplicationMain (in AppKit) + 880 [0x19c00d35c]
+ 2480 -[NSApplication run] (in AppKit) + 480 [0x19c036c64]
+ 2480 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit) + 688 [0x19c9e25b0]
+ 2480 _DPSNextEvent (in AppKit) + 684 [0x19c043ab4]
+ 2480 _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox) + 76 [0x1a3d3e484]
+ 2480 ReceiveNextEventCommon (in HIToolbox) + 676 [0x1a3bb34e8]
+ 2480 RunCurrentEventLoopInMode (in HIToolbox) + 324 [0x1a3bb027c]
+ 2480 CFRunLoopRunSpecific (in CoreFoundation) + 572 [0x19811bc58]
+ 2480 __CFRunLoopRun (in CoreFoundation) + 1980 [0x19811ca9c]
+ 2480 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ (in CoreFoundation) + 16 [0x19815bda4]
+ 2480 _dispatch_main_queue_callback_4CF (in libdispatch.dylib) + 44 [0x197e89cec]
+ 2480 _dispatch_main_queue_drain (in libdispatch.dylib) + 180 [0x197e89db0]
+ 2480 _dispatch_main_queue_drain.cold.5 (in libdispatch.dylib) + 812 [0x197eb1b58]
+ 2480 _dispatch_client_callout (in libdispatch.dylib) + 16 [0x197e9485c]
+ 2480 _dispatch_call_block_and_release (in libdispatch.dylib) + 32 [0x197e7ab2c]
+ 2480 thunk for @escaping @callee_guaranteed () -> () (in myAgent.debug.dylib) + 48 [0x103f44a3c] /<compiler-generated>:0
+ 2480 closure #1 in closure #9 in AppDelegate.applicationDidFinishLaunching(_:) (in myAgent.debug.dylib) + 24508 [0x10401625c] /<compiler-generated>:0
+ 2480 callbackHandler.currPage.modify (in myAgent.debug.dylib) + 44 [0x103ff84ec] /<compiler-generated>:0
+ 2480 callbackHandler.currPage.setter (in myAgent.debug.dylib) + 204 [0x103ff8470] myApp.swift:81
+ 2480 callbackHandler.currentPage.setter (in myAgent.debug.dylib) + 120 [0x103ff7850] myApp.swift:0
+ 2480 static Published.subscript.setter (in Combine) + 84 [0x1abbe3500]
+ 2480 specialized static Published.subscript.setter (in Combine) + 60 [0x1abbe4648]
+ 2480 specialized static Published.withMutation<A>(of:keyPath:storage:apply:) (in Combine) + 556 [0x1abbe45b0]
+ 2480 closure #1 in static Published.subscript.setter (in Combine) + 428 [0x1abbe3724]
+ 2480 PublishedSubject.send(_:) (in Combine) + 192 [0x1abbbc558]
+ 2480 ObservableObjectPublisher.send() (in Combine) + 636 [0x1abbd18fc]
+ 2480 ObservableObjectPublisher.Inner.send() (in Combine) + 176 [0x1abbd2244]
+ 2480 _os_unfair_lock_lock_slow (in libsystem_platform.dylib) + 176 [0x19806a324]
+ 2480 __ulock_wait2 (in libsystem_kernel.dylib) + 8 [0x197ffea54]
2480 Thread_87263447 DispatchQueue_22: com.apple.libtrace.state.block-list (serial)
+ 2480 start_wqthread (in libsystem_pthread.dylib) + 8 [0x19802db74]
+ 2480 _pthread_wqthread (in libsystem_pthread.dylib) + 292 [0x19802ee64]
+ 2480 _dispatch_workloop_worker_thread (in libdispatch.dylib) + 540 [0x197e8dae8]
+ 2480 _dispatch_root_queue_drain_deferred_wlh (in libdispatch.dylib) + 292 [0x197e8e264]
+ 2480 _dispatch_lane_invoke (in libdispatch.dylib) + 440 [0x197e83e60]
+ 2480 _dispatch_lane_serial_drain (in libdispatch.dylib) + 740 [0x197e83350]
+ 2480 _dispatch_client_callout (in libdispatch.dylib) + 16 [0x197e9485c]
+ 2480 _dispatch_call_block_and_release (in libdispatch.dylib) + 32 [0x197e7ab2c]
+ 2480 ___os_state_request_for_self_block_invoke (in libsystem_trace.dylib) + 372 [0x197d827a8]
+ 2480 _dispatch_sync_f_slow (in libdispatch.dylib) + 148 [0x197e8a640]
+ 2480 __DISPATCH_WAIT_FOR_QUEUE__ (in libdispatch.dylib) + 368 [0x197e8aa88]
+ 2480 _dispatch_thread_event_wait_slow (in libdispatch.dylib) + 56 [0x197e7cadc]
+ 2480 _dlock_wait (in libdispatch.dylib) + 56 [0x197e7ccbc]
+ 2480 __ulock_wait (in libsystem_kernel.dylib) + 8 [0x197ff29b8]
Take a look at the documentation for debugging techniques that has guidance on debugging common reasons for a crash. If you get stuck, let us know what you tried, and attach the fully symbolicated Apple crash report in your reply. Posting a Crash Report explains how to do so.