I get an unhandled exception with an access violation in the “juce_Atomic::compareAndSetValue” method in an RTAS plugin on windows.
Is it possible that the fact that the RTAS PlugInLibrary is by default compiled with 2byte alignment makes any problems here?
This is code where the access violation occours (juce_Atomic line 366):
return sizeof (Type) == 4 ? castFrom32Bit ((int32) juce_InterlockedCompareExchange ((volatile long*) &value, (long) castTo32Bit (newValue), (long) castTo32Bit (valueToCompare)))
: castFrom64Bit ((int64) juce_InterlockedCompareExchange64 ((volatile __int64*) &value, (__int64) castTo64Bit (newValue), (__int64) castTo64Bit (valueToCompare)));
This code is called by a SpinLock in the IIRFilter class:
void IIRFilter::processSamples (float* const samples,
const int numSamples) noexcept
const SpinLock::ScopedLockType sl (processLock);
This is a simple test plugin with just a call to an IIRFilter->processSamples in the processBlock.
The plugin and IIRFilter works fine for every other plugin format but crashes RTAS.
The juce_Atomic::compareAndSetValue is called pretty often in the plugin without any problems as long as it isn’t called from the DigiPlatformSupport.dll Thread.
All the calls to juce_Atomic::compareAndSetValue from any other Thread (MessageThread) do not make any problems for the RTAS plugin but the SpinLock of the IIRFilter calls this from the DigiPlatformSupport.dll Thread and that results in an access violation.
Any idea what could be specific to the RTAS code? Maybe the 2byte alignment could be the problem?