scriptnode / convolution + oversampling = read access violation. mtx was 0x100.
-
I could use a hand debugging a crash I'm getting in scriptnode. I've traced this down to the oversampling node.
I have:
- convolution node wrapped in 4x oversampling
- dsp exported to dll
- dll loaded in hardcoded fx
The compiled vst plug-in is crashing when switching impulses.
Callstack:
> Convolution Test Debug.vst3!mtx_do_lock(_Mtx_internal_imp_t * mtx, const xtime * target) Line 88 C++ Convolution Test Debug.vst3!_Mtx_lock(_Mtx_internal_imp_t * mtx) Line 174 C++ Convolution Test Debug.vst3!std::_Mutex_base::lock() Line 50 C++ Convolution Test Debug.vst3!std::unique_lock<std::mutex>::unique_lock<std::mutex>(std::mutex & _Mtx) Line 134 C++ Convolution Test Debug.vst3!juce::WaitableEvent::wait(int timeOutMilliseconds) Line 33 C++ Convolution Test Debug.vst3!juce::Thread::wait(int timeOutMilliseconds) Line 302 C++ Convolution Test Debug.vst3!hise::ConvolutionEffectBase::reloadInternal() Line 648 C++ Convolution Test Debug.vst3!hise::ConvolutionEffectBase::handleAsyncUpdate() Line 273 C++ Convolution Test Debug.vst3!hise::ConvolutionEffectBase::setImpulse(juce::NotificationType sync) Line 222 C++ Convolution Test Debug.vst3!scriptnode::filters::convolution::setExternalData(const snex::ExternalData & d, int index) Line 53 C++ Convolution Test Debug.vst3!scriptnode::data::pimpl::plain<0,2>::setExternalData<scriptnode::filters::convolution>(scriptnode::filters::convolution & n, const snex::ExternalData & b, int index) Line 1003 C++ Convolution Test Debug.vst3!scriptnode::wrap::data<scriptnode::filters::convolution,scriptnode::data::pimpl::plain<0,2>>::setExternalData(const snex::ExternalData & data, int index) Line 874 C++ Convolution Test Debug.vst3!convolution_impl::instance::setExternalData(const snex::ExternalData & b, int index) Line 75 C++ Convolution Test Debug.vst3!scriptnode::wrap::node<convolution_impl::instance>::setExternalData(const snex::ExternalData & d, int index) Line 1394 C++ Convolution Test Debug.vst3!scriptnode::prototypes::static_wrappers<scriptnode::wrap::node<convolution_impl::instance>>::setExternalData(void * obj, const snex::ExternalData * d, int index) Line 211 C++ Convolution Test Debug.vst3!scriptnode::OpaqueNode::setExternalData(const snex::ExternalData & b, int index) Line 90 C++ Convolution Test Debug.vst3!hise::HardcodedSwappableEffect::DataWithListener::updateData() Line 112 C++ Convolution Test Debug.vst3!hise::HardcodedSwappableEffect::DataWithListener::onComplexDataEvent(hise::ComplexDataUIUpdaterBase::EventType t, juce::var newValue) Line 122 C++ Convolution Test Debug.vst3!hise::ComplexDataUIUpdaterBase::sendMessageToListeners(hise::ComplexDataUIUpdaterBase::EventType t, juce::var v, juce::NotificationType n, bool forceUpdate) Line 1146 C++ Convolution Test Debug.vst3!hise::ComplexDataUIUpdaterBase::Updater::timerCallback() Line 1106 C++ Convolution Test Debug.vst3!hise::PooledUIUpdater::timerCallback() Line 962 C++ Convolution Test Debug.vst3!hise::SuspendableTimer::Internal::timerCallback() Line 815 C++ Convolution Test Debug.vst3!juce::Timer::TimerThread::callTimers() Line 119 C++ Convolution Test Debug.vst3!juce::Timer::TimerThread::CallTimersMessage::messageCallback() Line 181 C++ Convolution Test Debug.vst3!juce::InternalMessageQueue::dispatchMessage(juce::MessageManager::MessageBase * message) Line 202 C++ Convolution Test Debug.vst3!juce::InternalMessageQueue::dispatchMessages() Line 240 C++ Convolution Test Debug.vst3!juce::InternalMessageQueue::messageWndProc(HWND__ * h, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 163 C++
The same setup works as expected without the oversampling node.
-
and the cure..... wrap dsp in a fix_block
-
@Dan-Korneff good catch.
-
I take it back. Not cured.
@Christoph-Hart does a read access violation associated with mtx sound familiar?
it's 100% related to oversampling, cause I can hammer the convolution node with impulse changes with no crash when oversampling isn't used. -
@Dan-Korneff it might just create internal buffers beyond a certain limit? Can you reliably make it crash with oversampling?
-
Can you reliably make it crash with oversampling?
yeah, here's a minimal example that uses a timer to toggle between impulses. The exact time it takes to crash isn't consistent, but it takes less than a minute.
I believe it may have something to do with multithreading.
https://hub.korneffaudio.com/index.php/s/MBtPXHXXtZYcLZW -
definitely something with multi-threading. I turned it off on the example project and I just ran the compiled plugin for over 10 minutes now. No crashes.
-
@Christoph-Hart anything else I can do to get this on your radar? I think it's the source of some Logic crash reports I'm getting with projects containing scriptnode/convoltion/oversampling.
-
@Dan-Korneff do I have to compile the minimal project to a plugin or does it crash in HISE too?
-
@Christoph-Hart You'll have to compile. It doesn't crash HISE.
-
@Dan-Korneff Alright. And do I have to run it in Logic or is it crashing in other hosts too?
And I assume you're using the latest HISE, right? I fixed a few multithreading issues with convolution in December.
-
@Christoph-Hart I'm using the commit from Feb 6.
I have only tested on PC with Reaper and Cubase, but the Logic crash reports I get are Memory Access error so I'm assuming it's related. -
I'm having trouble with the oversampling as well but not on convolution, on just sample based instruments. The weird thing is: I have built some to success using oversample2x. But I have one project using 3 samplers unisono and this leads to crashing my DAW, though I have plugins running, that make extensive use of oversampling.
Currently, I'm running a build of the latest develop branch. Everything else is fine.
-
@Frankbeat It might be the case that the oversampling will lead to audio buffer sizes that exceed the streaming buffers for the voices (I implemented oversampling after putting up all safeguards for the streaming engine so I wouldn't be surprised if this creates an edge case that leads to a buffer overflow).
Can you reliably reproduce that? I can take a look at an example that crashes deterministically.
-
@Christoph-Hart I just noticed issues with oversampling not related to convolution as well.
-
@Christoph-Hart From now, it could take me a few days to reply with a sample of the project, but what you describe seems to make sense. AFAIK the generic buffer size is set to 512. I will see if it helps to increase that. My other plugins based on 1 or 2 samplers are fine with double rate oversampling.
-
Okay, now I have investigated on this… I Changed the buffer size in HISE Settings –> All to 1024. Now it doesn't crash anymore. But this is only tested for 2x so far
-
If I want my whole plugin to oversample its processes, do I even need to set the Oversampler as ScriptFX? Or can I just paste
Engine.setMinimumSampleRate(88200)
into my Init script?
-
@Frankbeat no actually if you use both the oversamplers stack onto each other.
-
This post is deleted!