MultiOutSynth demo plugin crash (VST3)

Hi,

I think there is a bug either in the VST3 wrapper or in the juce plugin host. Here is how to trigger the crash:

Add these lines in the processBlock() of MultiOutSynth:

for (int c=0; c < buffer.getNumChannels(); ++c) {
    float *p = buffer.getWritePointer(c);
     *p = 0;
}

(they just make sure we are trying to write in each output channel of the supplied AudioSampleBuffer)

Build the plugin with “Address Sanitizer” enabled in xcode.

Open the VST3 in the Juce Plugin Host. Select ‘Configure Audio I/O’. Disable bus #2 (the UI is maybe a bit buggy so it may need more than one click on the checkbox to get it really disabled). When closing the ‘Configure Audio I/O’ , I’m getting this crash:

==91715==ERROR: AddressSanitizer: heap-use-after-free on address 0x6310000a2110 at pc 0x000118fd0d06 bp 0x700002b3b850 sp 0x700002b3b848
WRITE of size 4 at 0x6310000a2110 thread T5
    #0 0x118fd0d05 in MultiOutSynth::processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) MultiOutSynth.cpp:101
    #1 0x118f8a163 in void juce::JuceVST3Component::processAudio<float>(Steinberg::Vst::ProcessData&, juce::Array<float*, juce::DummyCriticalSection, 0>&) juce_VST3_Wrapper.cpp:2143
    #2 0x118f6b8c8 in juce::JuceVST3Component::process(Steinberg::Vst::ProcessData&) juce_VST3_Wrapper.cpp:1957
    #3 0x118f6bbab in non-virtual thunk to juce::JuceVST3Component::process(Steinberg::Vst::ProcessData&) juce_VST3_Wrapper.cpp:1926
    #4 0x105ada468 in void juce::VST3Classes::VST3PluginInstance::processAudio<float>(juce::AudioBuffer<float>&, juce::MidiBuffer&, Steinberg::Vst::SymbolicSampleSizes) juce_VST3PluginFormat.cpp:2030
    #5 0x105ad1794 in juce::VST3Classes::VST3PluginInstance::processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) juce_VST3PluginFormat.cpp:1992
    #6 0x105abd385 in juce::GraphRenderingOps::ProcessBufferOp::callProcess(juce::AudioBuffer<float>&, juce::MidiBuffer&) juce_AudioProcessorGraph.cpp:281

Your code writes to all channels of the buffer even if the buffer of a particular bus is disabled. For multi-bus plug-ins you should be using busBuffer = AudioProcessor::getBusBuffer and then loop through the busBuffer.getNumChannels() channels. This is exactly what the demo does already and this does not crash the host.

Hi Fabian, I had also tried that and it crashes also:

const int busCount = getBusCount (false);
std::cerr << " numch=" << getTotalNumOutputChannels() << "\n";
for (int busNr = 0; busNr < busCount; ++busNr)
{
    AudioSampleBuffer audioBusBuffer = getBusBuffer (buffer, false, busNr);
    std::cerr << "Bus: " << busNr << "/" <<busCount << " enabled=" << getBus(false, busNr)->isEnabled() << " nch=" << getBus(false, busNr)->getNumberOfChannels() << " == " << audioBusBuffer.getNumChannels() << "\n";
    for (int c=0; c < audioBusBuffer.getNumChannels(); ++c) {
        float *p = audioBusBuffer.getWritePointer(c);
        *p = 0;
    }
}

Can’t seem to reproduce this with your code. Which version of Cubase are you using?

I’m using the Juce Plugin Host, sorry I should have written that more clearly in the subject. I feel it is more likely an issue with the juce host code than with the vst3 wrapper

A fix for the crash will appear on develop shortly, but it still does not fix it entirely: any buses above the disabled bus do not carry any audio. I’ll continue to investigate.

OK this is now fixed on develop. Thank you for reporting!

1 Like

Thanks Fabian, it seems to work fine :slight_smile: