AudioPluginDemo is crashing Dorico 3.5.12

In order to reproduce, start a new empty project in Dorico, on macOS. Click on the ‘Play’ button in Dorico (upper left corner), click on the ‘+’ button in the ‘VST Instruments’ pane on the right of the interface , add AudioPluginDemo twice.

Save the project, close it. Quit dorico, restart Dorico load the project a few times, the crash happens very quickly here. With AudioPluginDemo (build on latest develop JUCE branch) the call stack do not show much:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.steinberg.vst3.vstaudioengine	0x000000010d81d22b 0x10d2cc000 + 5575211
1   com.steinberg.vst3.vstaudioengine	0x000000010d90e6e5 0x10d2cc000 + 6563557
2   com.steinberg.vst3.vstaudioengine	0x000000010d90e635 0x10d2cc000 + 6563381

However with my plugin, the crash happens inside the vst3 wrapper:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ???                           	0x00007f958bd5c570 0 + 140280272897392
1   com.foo.MyPlugin. VST3	0x000000010f2c0001 juce::JucePluginFactory::release() + 33 (juce_VST3_Wrapper.cpp:3530)

With an older version of AudioPluginDemo based on juce 6.0.7, I got:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ???                           	0x0000000000000001 0 + 1
1   com.JUCE.AudioPluginDemo      	0x0000000110e29e91 juce::ComSmartPtr<Steinberg::Vst::IHostApplication>::~ComSmartPtr() + 49
2   com.JUCE.AudioPluginDemo      	0x0000000110e29dd5 juce::ComSmartPtr<Steinberg::Vst::IHostApplication>::~ComSmartPtr() + 21
3   com.JUCE.AudioPluginDemo      	0x0000000110e29f10 juce::JucePluginFactory::~JucePluginFactory() + 96
4   com.JUCE.AudioPluginDemo      	0x0000000110e28f45 juce::JucePluginFactory::~JucePluginFactory() + 21
5   com.JUCE.AudioPluginDemo      	0x0000000110e28f6c juce::JucePluginFactory::~JucePluginFactory() + 28
6   com.JUCE.AudioPluginDemo      	0x0000000110e2890e juce::JucePluginFactory::release() + 78

I’m unable to repro this on the very latest develop (73523cd, Dorico 3.5.12, macOS 10.15.7).

The crashes you’re seeing look like they might be caused by a refcounting bug. There was a short window of time between the 13th of May (52e6c4f) and the 21st of May (2f04d6a8) where JUCE was incorrectly doing manual refcounting on a smart pointer in one of the VST3 SDK classes. If you were using a custom version of the VST3 SDK with a copy of JUCE from before the 21st of May, there’s a chance you may have run into the same issue. Are you able to reproduce the issue with a copy of JUCE from after the 21st of May?

Yes I still can reproduce it with develop 73523cd , Dorico 3.5.12, macOS 10.15.7. The stack trace I am now getting is this one:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.JUCE.AudioPluginDemo      	0x00000001101d8cd8 juce::VSTComSmartPtr<Steinberg::Vst::IHostApplication>::~VSTComSmartPtr() + 40 (juce_VST3Common.h:367)
1   com.JUCE.AudioPluginDemo      	0x00000001101d8c25 juce::VSTComSmartPtr<Steinberg::Vst::IHostApplication>::~VSTComSmartPtr() + 21 (juce_VST3Common.h:367)
2   com.JUCE.AudioPluginDemo      	0x00000001101d8d60 juce::JucePluginFactory::~JucePluginFactory() + 96 (juce_VST3_Wrapper.cpp:3474)
3   com.JUCE.AudioPluginDemo      	0x00000001101d7d95 juce::JucePluginFactory::~JucePluginFactory() + 21 (juce_VST3_Wrapper.cpp:3474)
4   com.JUCE.AudioPluginDemo      	0x00000001101d7dbc juce::JucePluginFactory::~JucePluginFactory() + 28 (juce_VST3_Wrapper.cpp:3471)
5   com.JUCE.AudioPluginDemo      	0x00000001101d775e juce::JucePluginFactory::release() + 78 (juce_VST3_Wrapper.cpp:3494)
6   com.steinberg.vst3.vstaudioengine	0x00000001041c726a 0x103b53000 + 6767210

Maybe I can send you my Dorico project (it contains only two instances of AudioPluginDemo). Just opening it and closing dorico triggers the crash.

I’d like to try debugging your project file, if you could send me a copy.

Edit: Sorry, just tried again and I can repro it now! I’ll investigate and update this thread if I find a fix.