Cubase 4+5 crash after removing juce vst from 5.1 channel


#1

I checked this issue with current juce from svn and the juceDemoPlugin
If you are using 2-in/out channel plugin on a surround track, cubase will crash AFTER you have removed the plugin from the mixer.

The debugger indicates that there is a heap-corruption

Windows has triggered a breakpoint in Cubase5.exe.

This may be due to a corruption of the heap, which indicates a bug in Cubase5.exe or any of the DLLs it has loaded.

Is it possible that something in VST-Wrapper is corrupting the heap?


#2

Hmm. Sounds like it’ll involve 6 channel data getting written into a 2 channel space and overflowing the end. Can’t think where that’d happen though - if the host is providing more channels than the plugin wants, it shouldn’t have any chance to go wrong…


#3

Ok, i realized this problem happens when the initial (maximal) number of channels is smaller than then channels set by setSpeakerArrengment.
Maybe this is a inconsistency inside Cubase, and Cubase has a bug inside (the corrupts the heap)

So i come to the conclusion that the maximal-channels (set by AudioEffect::setNumInputs()/Output() have to be updated)

This is what I’ve done, it works fine so far (tested in Cubase 4)

 bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput,
                                VstSpeakerArrangement* pluginOutput)
    {
        // if this method isn't implemented, nuendo4 + cubase4 crash when you've got multiple channels..


	     if  ((  numInChans != pluginInput->numChannels )
	        	|| ( numInChans != pluginInput->numChannels ))
	     {
	     	  setNumInputs (pluginInput->numChannels);
	     	  setNumOutputs (pluginOutput->numChannels);
	     	  ioChanged ();
	     };


        numInChans = pluginInput->numChannels;
        numOutChans = pluginOutput->numChannels;

        filter->setPlayConfigDetails (numInChans, numOutChans,
                                      filter->getSampleRate(),
                                      filter->getBlockSize());

        return true;
    }

#4

Ok, that makes some sense - I’ll go with your suggestion and see what happens - thanks!


#5

oops, small correction… (numOutChans != pluginOutput->numChannels)

[code] bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput,
VstSpeakerArrangement* pluginOutput)
{
// if this method isn’t implemented, nuendo4 + cubase4 crash when you’ve got multiple channels…

	if  ((  numInChans != pluginInput->numChannels )
		|| ( numOutChans != pluginOutput->numChannels ))
	{
		  setNumInputs (pluginInput->numChannels);
		  setNumOutputs (pluginOutput->numChannels);
		  ioChanged ();
	};


    numInChans = pluginInput->numChannels;
    numOutChans = pluginOutput->numChannels;

    filter->setPlayConfigDetails (numInChans, numOutChans,
                                  filter->getSampleRate(),
                                  filter->getBlockSize());

    return true;
}

[/code]
[/code]


#6

Don’t worry, I’d already spotted that!


#7

oh, i just see, the solution i mentioned isn’t perfect, cubase will crash too, if you open several instances of the same plugin (on a surround channel).

Its better to set JucePlugin_MaxNumInputChannels/OutputChannes with 6 ore more channels, BUT this will result in incompatibility with hosts like Adobe Audition, which doesn’t support more than 2 channels.

Has someone an idea?


#8

I have what I think is the same problem here http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?t=3943

chkn it seems we are running into the same issues all the time!

Andrew Simper


#9

I have found this workaround:

[code]bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput,
VstSpeakerArrangement* pluginOutput)
{
// if this method isn’t implemented, nuendo4 + cubase4 crash when you’ve got multiple channels…
#ifdef USE_ALL_SPEAKER_CONFIGS
numInChans = pluginInput->numChannels;
numOutChans = pluginOutput->numChannels;

    filter->setPlayConfigDetails (numInChans, numOutChans,
                                  filter->getSampleRate(),
                                  filter->getBlockSize());
	
    return true;

#else

	if ((pluginInput->type == kSpeakerArrMono) || (pluginInput->type == kSpeakerArrStereo)) 
	{
		numInChans = pluginInput->numChannels;
		numOutChans = pluginOutput->numChannels;

		filter->setPlayConfigDetails (numInChans, numOutChans,
                                  filter->getSampleRate(),
                                  filter->getBlockSize());
		return true;
	}
	else return false;

#endif
}[/code]

where I define USE_ALL_SPEAKER_CONFIGS only if I write a plugin that can really handle everything that the host throws at it. If I have a stereo plugin (that can also handle mono, but not 5.1 or something like that) then what happens on a Cubase 5.1 channel is that only the first two channels are routed through the plugin and the other four bypass it. Seems to work fine so far, no complaint from anybody.


#10

Well I have a main stereo in and a second stereo in for an external sidechain signal, and a single stereo output. Not sure how that fits into the speaker arrangements you are using. I do handle all that a host can throw at the plugin, in my process I check the input and output count, but external sidechaining in cubase doesn’t even work when I do that!

Andrew Simper


#11

Hmmm… did you try it with a 4 in/4 out configuration already (on a quattro channel) ? Just a wild guess…


#12

I insert a 4 in, 2 output version of the juce demo plugin on a quadro channel and it crashes on exit as I have indicated in the other thread here on the forum.

Andrew Simper


#13

Yes, I read that. That’s why I suggested a 4 in/4 out test.