[Closed] Convolution crash while switching local IR file

Hi JUCE team, I’m using the ConvolutionEngine for my plugin, but I got occasional crash while switching IR file, and the alert message is like this:

I also attached the files triggering the crash below:

No matter loading IR from buffer or local file, all have these crash after switching these IR files a few times, not sure what’s the problem, any suggestions?

Btw these IR files combines of really short amp IR and long reverb IR, and I’m using the latest JUCE development commit.

Thanks in advance! @IvanC @reuk

Have you tested any of the JUCE demos that include a Convolution (ConvolutionDemo, DSPModulePluginDemo)? You could try modifying the ConvolutionDemo to load your impulse responses and check whether it still crashes. If not, then the problem is probably not in the Convolution itself.

1 Like

Hi, thanks for the reply. I just tried with my files in the JUCE demo, it works great, and I have narrowed the bug to be a EXC_BAD_ACCESS somewhere in Convolution::Mixer::processBlock, seems it’s allocating some released data.

The only difference between my code and the demo that I can analyze might be the IR reading source, in demo it’s reading from demo project included asset, but my user case is reading from user’s local file, does that mean I have to save the previous file entirely into maybe a daw project memory data like APVTS for the smooth IR switching?

If the problem isn’t present in the ConvolutionDemo, then the issue is probably due to some aspect of your particular project.

A handy tool for tracking down segfaults is Address Sanitizer. You can enable this in Xcode by going to the target drop-down at the top of the window, clicking “edit scheme”, and then enabling Address Sanitizer from the “Diagnostics” tab. Then, when your application reads or writes to an address that is invalid for some reason, it will print some helpful information to the console explaining the problem.

1 Like

Thanks, I just used the AddressSanitizer, and it says this:

SUMMARY: AddressSanitizer: heap-use-after-free juce_FloatVectorOperations.cpp:50 in juce::FloatVectorHelpers::BasicOps32::loadA(float const)*

and here’s the warning in Xcode:

and sometimes it warns here, but the same summary:

My method is loading a local file into a reader then use exactly how JUCE demo apples it to the buffer in processBlock, crash after switching IR files a few times. And I also tried loading from local file method like this demo from viatordsp, and his demo also crashes on IR switching (you can download his project and try).

The main difference I can tell is JUCE demo is using IR files which comes from builtin asset, not local dragged file, which might have something wrong with how Convolution deals with new IR file loading.

And I also checked the JUCE Document, but it didn’t say anything special for loadImpulseResponse() from local files.

https://docs.juce.com/master/classdsp_1_1Convolution.html#a2d74d8ab7945f4805cd00ad1d67f08de

So I really wonder if there’s anything special I need to do while using loadImpulseResponse() from local files :rofl:

The problem in the demo you linked is here:

Calling loadImpulseResponse from one thread while another thread is calling process is not supported. This is explained in the documentation for the Convolution class:

I expect that your program has the same problem. Please take another look at the ConvolutionDemo for an approach to loading impulse response files from the main thread and communicating them to the audio thread.

1 Like

Thanks again for helping, I checked my code, it’s the prepare() function being called too many times, might got mislead by some information ( sorry for my bad English :sweat_smile: )

1 Like