Trouble figuring out error crash - terminating with uncaught exception of type std::__1::bad_function_call: std::exception

Hello!

Been struggling to figure out this cause of this crash on a plugin im working on.

When I change presets while playing sometimes it causes this crash.

libc++abi.dylib: terminating with uncaught exception of type std::__1::bad_function_call: std::exception

Let me know if these screen shots are not enough info!
Any help is seriously appreciated!

This exception fires when you try to call a std::function object that is empty (perhaps because it has been default-inialised or cleared).

Perhaps when you load a preset, the waveshaper function is being cleared somehow.

Another possibility is that there is a data race on this function object. If you’re loading the preset on the main thread while the waveshaper is being used on the audio thread, you may need to add explicit synchronisation to avoid a race.

1 Like

Thanks for your help @reuk ! Turned out to be a data race!