[Solved] Help with malloc error on AudioProcessor destructor


#1

I’m trying to debug a crash on shutdown, initially picked up by the leak detector, and now hitting a malloc error:

malloc: *** error for object 0x610000067b00: pointer being freed was not allocated

Its coming from the AudioProcessor destructor:

Any pointers on how to debug this?

I’ve re-architected my app about 3 times this morning trying to solve this issue…!


#2

Open the schemes window and then go to the “Diagnostics” tab.
Enable “Address Sanitiser”. It’s one of the most useful tools ever to have been created and doesn’t really slow your app down too much (I have it on pretty much permanently unless I’m profiling).

You’ll have to rebuild and reproduce the crash again but you’ll get a stack report when you do of where the object was allocated and where it was destroyed.


#3

Thanks Dave, that definitely helped me to see what was going on… the AudioProcessorGraph::Node destructor was trying to delete already deallocated memory.

My mistake was instantiating AudioProcessors as class members - I’m now instantiating AudioProcessor pointers and handing them over to AudioProcessorGraph to manage.