MidiInput::getDevices breaks Cubase 9

Steinberg Cubase 9 blacklists our plugins on OS X 10.11 if we’re calling MidiInput::getDevices or MidiOutput::getDevices during initialization.

I’ve tested it with JUCE’s current master (v4.3.1), compiled with XCode 8.2.1 on OS X 10.11, and Base SDK set to 10.7.

Steinberg’s vst2xscanner gives this error: Segmentation fault: 11

If we avoid the call to MidiInput::getDevices or MidiOutput::getDevices, then our plugins are parsed fine.

Also all is fine on macOS 10.12, even if we call MidiInput::getDevices or MidiOutput::getDevices.

Do you really need to interact with MIDI devices in during initialisation? It seems like a pretty dangerous thing to do as hosts instantiate plug-ins in loads of different contexts and threads.

Thank you for your answer! It simplifies stuff a lot if we initialize MIDI devices during initialization, but we could also initialize it later. But if it’s unsafe to do during initialization, how can I be sure doing it later is safe?

I don’t know what exactly Steinberg is doing in their vstscanner tool, which prints the segmentation faults, but I’d guess they have only one thread running, that initializes the plugin.

Good question. Is is possible to scan for devices in prepareToPlay?

I’m not suggesting that this isn’t something that’s fixable, but even if we do fix it I would still advise being very conservative when you scan.

Yes, we can do that - so thank you for the hint, sounds like a good place to do it in prepareToPlay .

I’ve just built JUCE’s audio plugin demo on JUCE’s current master and tested it with OS X 10.11.

JUCE’s plugin demo gets blacklisted in Cubase 9 if I call MidiOutput::getDevices (or MidiInput…) at the end of the constructor of JuceDemoPluginAudioProcessor. And Steinberg’s vst2xscanner gives this error: Segmentation fault: 11

If I call MidiOutput::getDevices in prepareToPlay instead, then JUCE’s plugin demo is not blacklisted, and the scan works fine.

Still - I wonder if the reported Segmentation fault: 11 means there’s something bad going on in MidiOutput::getDevices that might needs to be addressed. It would be great if the JUCE team can have a look at it.

Of course we don’t know why Steinberg’s vst2xscanner prints a “Segmentation fault” after calling MidiOutput::getDevices_, still I think it’d be valuable if the JUCE team could have a look at this.

JUCE team, is this something you will look into, or will you ignore it?

Did you get a stack trace at any point? If it’s our code that’s crashing rather than Steinberg’s then we may want to dig a bit deeper.

No stack trace - the code is getting executed all fine. It’s just Steinberg’s scanner that afterwards prints the “Segmentation fault” message (instead of printing the details of the plugin and channel configuration).

OK, I’ve just verified this again - it’s not the JUCE code that’s crashing. But still, it requires the call to MidiOutput::getDevices_ and then Steinberg’s vst2xscanner is crashing.

OK, well I’m really not sure what we could possibly do to stop that - if you look inside that function call you’ll see that it does pretty much nothing except call the OS MIDI enumerator…

Ah ok. I’ll pass this on to Steinberg’s developers via their forum.

May I add a link to a compiled debug version of the JUCE demo plugin in the forum post?

Thanks, yes, that sounds like the best plan. I don’t think anyone else would be able to figure out what’s going wrong in their code.