JUCE VST3 plugins seem to crash Dorico 5 on exit on macOS 15.
Procedure:
Build a JUCE VST3 plugin.
Create a new Dorico 5 project on macOS and load the JUCE plugin on a channel.
Quit Dorico.
Result:
The VST Audio Engine process crashes. Running under a debugger, I see that the crash happens when calling IHostApplication::release.
I think this is what’s happening:
Dorico calls IPluginFactory3::setHostContext() on the JUCE plugin factory. In the implementation of this function, the plugin increments the refcount on the IHostApplication pointer, and stores it. When Dorico’s audio engine quits, it calls release on the JUCE plugin factory. The plugin factory is still holding a pointer to the IHostApplication, and calls release on this pointer. However, at this point, the IHostApplication has already been freed (incorrectly, because the plugin still holds a reference to it), and the program crashes.
I’m one of the JUCE maintainers. Having debugged this a bit, it certainly looks like a refcounting issue on Dorico’s side. I think that Dorico is freeing the IHostApplication object while the JUCE IPluginFactory3 is still holding a reference to it, which isn’t allowed.
Potential fixes for the issue might be:
Avoid deleting the IHostApplication instance until all VST3 plugin factories have been freed.
If the IHostApplication needs to be destroyed earlier than that for some reason, perhaps setHostContext (nullptr) could be called on each plugin factory before the IHostApplication is destroyed, so that the factories drop their internal references.
This one has been going on for a while… I hope you’ll squash it once and for all (my default reverbs, relab development’s ones, cause that crash each and every day)