DeadLock in __psynch_cvwait(Apple Silicon)

Hello,

I am experiencing hang in one of our instrument plugins when moving using next preset(using '[' shortcut) in Logic's preset mechanism.

In the debugger I noticed that the hang is caused by __psynch_cvwait called from NSMenu insertItem:atIndex

The hang isn't reproduced when running Logic through Rosetta on BigSur, happens only on M1 machine.


Thanks,
Max.


Answered by DTS Engineer in 676635022

I uploaded the spin dump of the relevant process

Thanks for that.

So I’m presuming that thread 0x9d8698 is the problem here. If so, here’s a backtrace that I synthesised from the spin dump:

 0 psynch_cvcontinue + 0 (pthread + 17300) [0xfffffe000a988394]
 1 __psynch_cvwait + 8 (libsystem_kernel.dylib + 17544) [0x189504488]
 2 _pthread_cond_wait + 1192 (libsystem_pthread.dylib + 30056) [0x18953a568]
 3 -[NSOperation waitUntilFinished] + 584 (Foundation + 348400) [0x18a3ac0f0]
 4 _CFXNotificationPost + 800 (CoreFoundation + 291040) [0x1895f80e0]
 5 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 (Foundation + 42576) [0x18a361650]
 6 -[NSMenu insertItem:atIndex:] + 624 (AppKit + 216644) [0x18bdffe44]
 7 wvWavesV13_0_0_54::PluginViewManager::WCPluginViewManagerMacCocoa::AddMenuItem(WSMenu*, wvWavesV13_0_0_54::P…
 8 wvWavesV13_0_0_54::PluginViewManager::AddMenuItem(WSMenu*, wvWavesV13_0_0_54::PluginViewManager::WCMenuItemI…
 9 cCODEX_ALG::UpdateWavetableMenu(int) + 604 (CODEXAlg.cpp:584,9 in CODEXDebug + 34176) [0x112c48580]
10 cCODEX_ALG::UpdateAlgSelf() + 732 (CODEXAlg.cpp:638,5 in CODEXDebug + 35492) [0x112c48aa4]
11 cALGORITHM::UpdateAlg() + 144 (cALGORITHM.cpp:6371,18 in WavesLib + 4078744) [0x10f9ffc98]
12 cALGORITHM::UpdateDSPCoefs(bool) + 96 (cALGORITHM.cpp:3421,34 in WavesLib + 4078020) [0x10f9ff9c4]
13 cALGORITHM::LoadFactoryPresetByIndex(unsigned long) + 496 (cALGORITHM.cpp:4436,9 in WavesLib + 4103000) [0x1…
14 SetPluginInfo_size_t(wvWavesV13_0_0_54::PluginInstance&, unsigned int, unsigned long, long) + 160 (PluginInf…
15 WP_SetPluginInfo_size_t + 120 (API_PluginInfo.cpp:132,26 in CODEXDebug + 813404) [0x112d0695c]
16 wvWavesV13_0_0_54::WCPluginInstanceProxy::SetPluginInfo(WCSetPluginInfo_size_t_selector, unsigned long, long…
17 WCWaveShell_AU_Base::BaseNewFactoryPresetSet(AUPreset const&) + 140 (WCWaveShell_AU_Base.cpp:2393,19 in Wave…
18 WCWaveShell_AU_Instrument::NewFactoryPresetSet(AUPreset const&) + 120 (WCWaveShell_AU_Instrument.cpp:603,44 …
19 AUBase::DispatchSetProperty(unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 2684 (AUB…
20 AUMethodSetProperty(void*, unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 124 (AUPlu…
21 setPresentPresetAndNotify(AUAudioUnitV2Bridge*, AUAudioUnitPreset*) + 128 (AudioToolboxCore + 1565880) [0x18…
22 -[AUAudioUnitV2Bridge _setValue:forKey:error:] + 304 (AudioToolboxCore + 1564116) [0x18aa7bdd4]
23 -[AURemoteHost setValue:forProperty:propagateError:reply:] + 264 (AudioToolboxCore + 360132) [0x18a955ec4]
24 __invoking___ + 148 (CoreFoundation + 411796) [0x189615894]
25 -[NSInvocation invoke] + 448 (CoreFoundation + 411420) [0x18961571c]
26 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT__ + 24 (Foundation + 807844) [0x18a41c3a4]
27 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 1316 (Foundation + 450988) [0x18a3c51ac]
28 message_handler + 228 (Foundation + 143144) [0x18a379f28]
29 _xpc_connection_call_event_handler + 164 (libxpc.dylib + 55640) [0x1892a5958]
30 _xpc_connection_mach_event + 960 (libxpc.dylib + 50272) [0x1892a4460]
31 _dispatch_client_callout4 + 20 (libdispatch.dylib + 17644) [0x18938d4ec]
32 _dispatch_mach_msg_invoke + 472 (libdispatch.dylib + 124432) [0x1893a7610]
33 _dispatch_lane_serial_drain + 272 (libdispatch.dylib + 46664) [0x189394648]
34 _dispatch_mach_invoke + 468 (libdispatch.dylib + 127776) [0x1893a8320]
35 _dispatch_lane_serial_drain + 272 (libdispatch.dylib + 46664) [0x189394648]
36 _dispatch_lane_invoke + 460 (libdispatch.dylib + 49920) [0x189395300]
37 _dispatch_workloop_worker_thread + 708 (libdispatch.dylib + 91132) [0x18939f3fc]
38 _pthread_wqthread + 276 (libsystem_pthread.dylib + 12384) [0x189536060]
39 start_wqthread + 8 (libsystem_pthread.dylib + 7572) [0x189534d94]

First up, I want to point that this is a Dispatch worker thread, not the main thread. Second, check out frames 7 and 6. It looks like your code, wvWavesV13_0_0_54::PluginViewManager::WCPluginViewManagerMacCocoa::AddMenuItem(…), is calling AppKit’s -[NSMenu insertItem:atIndex:]. However, AppKit is a main-thread-only framework (with a few exceptions), making that illegal.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

There’s not a lot to go on here. Can you post a spin dump? Use the text attachment feature (the paperclip icon) to avoid clogging up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Eskimo,

I uploaded the spin dump of the relevant process but let me know if you need the full system spin dump or any other info.

Thanks, Max.

Accepted Answer

I uploaded the spin dump of the relevant process

Thanks for that.

So I’m presuming that thread 0x9d8698 is the problem here. If so, here’s a backtrace that I synthesised from the spin dump:

 0 psynch_cvcontinue + 0 (pthread + 17300) [0xfffffe000a988394]
 1 __psynch_cvwait + 8 (libsystem_kernel.dylib + 17544) [0x189504488]
 2 _pthread_cond_wait + 1192 (libsystem_pthread.dylib + 30056) [0x18953a568]
 3 -[NSOperation waitUntilFinished] + 584 (Foundation + 348400) [0x18a3ac0f0]
 4 _CFXNotificationPost + 800 (CoreFoundation + 291040) [0x1895f80e0]
 5 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64 (Foundation + 42576) [0x18a361650]
 6 -[NSMenu insertItem:atIndex:] + 624 (AppKit + 216644) [0x18bdffe44]
 7 wvWavesV13_0_0_54::PluginViewManager::WCPluginViewManagerMacCocoa::AddMenuItem(WSMenu*, wvWavesV13_0_0_54::P…
 8 wvWavesV13_0_0_54::PluginViewManager::AddMenuItem(WSMenu*, wvWavesV13_0_0_54::PluginViewManager::WCMenuItemI…
 9 cCODEX_ALG::UpdateWavetableMenu(int) + 604 (CODEXAlg.cpp:584,9 in CODEXDebug + 34176) [0x112c48580]
10 cCODEX_ALG::UpdateAlgSelf() + 732 (CODEXAlg.cpp:638,5 in CODEXDebug + 35492) [0x112c48aa4]
11 cALGORITHM::UpdateAlg() + 144 (cALGORITHM.cpp:6371,18 in WavesLib + 4078744) [0x10f9ffc98]
12 cALGORITHM::UpdateDSPCoefs(bool) + 96 (cALGORITHM.cpp:3421,34 in WavesLib + 4078020) [0x10f9ff9c4]
13 cALGORITHM::LoadFactoryPresetByIndex(unsigned long) + 496 (cALGORITHM.cpp:4436,9 in WavesLib + 4103000) [0x1…
14 SetPluginInfo_size_t(wvWavesV13_0_0_54::PluginInstance&, unsigned int, unsigned long, long) + 160 (PluginInf…
15 WP_SetPluginInfo_size_t + 120 (API_PluginInfo.cpp:132,26 in CODEXDebug + 813404) [0x112d0695c]
16 wvWavesV13_0_0_54::WCPluginInstanceProxy::SetPluginInfo(WCSetPluginInfo_size_t_selector, unsigned long, long…
17 WCWaveShell_AU_Base::BaseNewFactoryPresetSet(AUPreset const&) + 140 (WCWaveShell_AU_Base.cpp:2393,19 in Wave…
18 WCWaveShell_AU_Instrument::NewFactoryPresetSet(AUPreset const&) + 120 (WCWaveShell_AU_Instrument.cpp:603,44 …
19 AUBase::DispatchSetProperty(unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 2684 (AUB…
20 AUMethodSetProperty(void*, unsigned int, unsigned int, unsigned int, void const*, unsigned int) + 124 (AUPlu…
21 setPresentPresetAndNotify(AUAudioUnitV2Bridge*, AUAudioUnitPreset*) + 128 (AudioToolboxCore + 1565880) [0x18…
22 -[AUAudioUnitV2Bridge _setValue:forKey:error:] + 304 (AudioToolboxCore + 1564116) [0x18aa7bdd4]
23 -[AURemoteHost setValue:forProperty:propagateError:reply:] + 264 (AudioToolboxCore + 360132) [0x18a955ec4]
24 __invoking___ + 148 (CoreFoundation + 411796) [0x189615894]
25 -[NSInvocation invoke] + 448 (CoreFoundation + 411420) [0x18961571c]
26 __NSXPCCONNECTION_IS_CALLING_OUT_TO_EXPORTED_OBJECT__ + 24 (Foundation + 807844) [0x18a41c3a4]
27 -[NSXPCConnection _decodeAndInvokeMessageWithEvent:flags:] + 1316 (Foundation + 450988) [0x18a3c51ac]
28 message_handler + 228 (Foundation + 143144) [0x18a379f28]
29 _xpc_connection_call_event_handler + 164 (libxpc.dylib + 55640) [0x1892a5958]
30 _xpc_connection_mach_event + 960 (libxpc.dylib + 50272) [0x1892a4460]
31 _dispatch_client_callout4 + 20 (libdispatch.dylib + 17644) [0x18938d4ec]
32 _dispatch_mach_msg_invoke + 472 (libdispatch.dylib + 124432) [0x1893a7610]
33 _dispatch_lane_serial_drain + 272 (libdispatch.dylib + 46664) [0x189394648]
34 _dispatch_mach_invoke + 468 (libdispatch.dylib + 127776) [0x1893a8320]
35 _dispatch_lane_serial_drain + 272 (libdispatch.dylib + 46664) [0x189394648]
36 _dispatch_lane_invoke + 460 (libdispatch.dylib + 49920) [0x189395300]
37 _dispatch_workloop_worker_thread + 708 (libdispatch.dylib + 91132) [0x18939f3fc]
38 _pthread_wqthread + 276 (libsystem_pthread.dylib + 12384) [0x189536060]
39 start_wqthread + 8 (libsystem_pthread.dylib + 7572) [0x189534d94]

First up, I want to point that this is a Dispatch worker thread, not the main thread. Second, check out frames 7 and 6. It looks like your code, wvWavesV13_0_0_54::PluginViewManager::WCPluginViewManagerMacCocoa::AddMenuItem(…), is calling AppKit’s -[NSMenu insertItem:atIndex:]. However, AppKit is a main-thread-only framework (with a few exceptions), making that illegal.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Eskimo,

Yes that makes sense why Rosetta works fine because we are receiving the changed preset event in main thread in contrast to ARM that we receive it in NSXPCConnection thread.

Is it the desired behaviour from Logic under ARM?

There is any documentation regarding it? and in general regarding Logic under ARM documentation?

Thanks

Is it the desired behaviour from Logic under ARM?

I’m sorry but I don’t know anything about Logic or audio units. Well, I know what they are, but I can’t speak to their developer story. My only suggestion is that, now that you understand the cause for the hang, you create a new thread with your questions about the expected runtime environment for audio units, making sure to tag that thread to attract audio folks (I think there’s an AudioUnit tag).

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I see, appreciate the help thanks.

DeadLock in __psynch_cvwait(Apple Silicon)
 
 
Q