Suspend in AAX possible race condition?


#1

I guess, in the AAX wrapper isSuspended() should be called BEFORE the call-back lock is acquired?

So that suspendProcessing(true) will guarantee no callback will happen after calling it?


#2

bump


#3

I can’t see how this would turn into a race condition. Could you spell it out more clearly?


#4

After calling suspendProcessing (true); it should be guaranteed that processBlock is NOT being executed.

This can only happen if in wrapper isSuspended() and processBlock are called under the SAME callback-lock scope.

Which seems to be guaranteed in VST, VST3 and AU but not in AAX.

There is a gap between calling isSuspended and acquiring the lock, if another thread calls setSuspended(true) while being in this gap -> processBlock will be called

 void process (const float* const* inputs, float* const* outputs, const int sideChainBufferIdx,
                      const int bufferSize, const bool bypass,
                      AAX_IMIDINode* midiNodeIn, AAX_IMIDINode* midiNodesOut,
                      float* const meterBuffers)
        {
         ...
         bool isSuspended = pluginInstance->isSuspended();
         ...             
         ...
         // lock will be acquired inside process(...) subroutine
         process (channels, numOuts, bufferSize, bypass, midiNodeIn, midiNodesOut);

#5

solution could be just move the
const ScopedLock sl (pluginInstance->getCallbackLock());
to the first process-method, before isSuspended


#6

OK, I see now - I thought your original post was saying that the check should be done before the callback lock is held.

That would certainly fix the race, but it’s unclear if it’ll cause any other issues. This will probably take some time to work out the neatest solution.


#7

Ah yes, sry for confusion.