Is it safe to call GetPluginFactory() in InitModule()?

Doing the above causes a crash in Studio One 3.5 on Windows 7 64bits with Studio One running as a 32Bit application.

The idea is to instanciate the plugin once after the dll was loaded to extract its factory presets as a set of vstpreset files (using PresetFile) otherwise exposed via a means of a program list parameter. This is done in order to support VST3 presets in cases where the latter API is not supported, e.g. Studio One or Samplitude, but leads to the described crash in Studio one.

It’s also worth mentioning that the exception occurs outside of the plugin code and after the plugin has been unloaded in a module linked by Studio One:

The crash happens in cclgui.dll (read access violation at address 0x52C91EA0), which accoding to the description contains Presonus’ Cross-platform UI framework.

All other plugins and the code that actually extracts the presets have been removed so it’s definitely stripped down to this particular scenario. So far I’ve only observed this in Studio One.

I think an installer would be the better solution for this use case. The GetPluginFactory method should return as fast as possible.


Hi Arne,

Thanks for getting back so quickly.

I see, however, the extraction step is only performed upon the first instanciation and the code under consideration is called in the InitModule() function, not GetPluginFactory(). So it really only happens once when the plugin is loaded for the first time and the time consuming step is skipped if the preset folder is already present. There is also another requirement for some plugins that are deployed via a distribution partner’s installer infrastructure in which plugins are (at least more or less) required to be self contained.

EDIT: Nevermind, I managed to find a workaround that’s stable. It seems that the mentioned dll doesn’t like COM to be uninitialized twice :slight_smile:. In other words, the reported crash was just a side effect of an unbalanced CoInitialize()/CoUninitialize() sequence. I assume the answer to my initial question is yes.