Hello everyone, this is my first time making a post because I really can’t find anything about this specific issue and it generally means that I personally did something wrong.
I am working with a few juce::HeapBlock<float> like i have been for some time now but I have a specific set of them that don’t act like the others and crash when reallocated. Here’s the exact error:
Upon investigation I figured out that the crash happens during std::free(data) upon reallocating or destroying the HeapBlock, and I cannot find why it happens to these and not the other HeapBlocks I have.
Here is how I define them:
juce::HeapBlock<float> blockMain, blockSide, blockOut;
Here is how I reallocate them:
blockMain.allocate(windowSize, true);
blockSide.allocate(windowSize, true);
blockOut.allocate(windowSizePadded, true);
/* my processing involves convolution so I need more space to store the output with an overlap-add method */
Here is how I use them:
// filling up from audio inputs
blockMain[headIn] = mainPtr[s];
blockSide[headIn] = sidePtr[s];
if (++headIn > windowSize) headIn = 0;
// filling up from computations output
outPtr[s] = blockOut[headOut];
blockOut[headOut] = 0.0f;
if (++headOut > windowSizePadded) headOut = 0;
/* headIn and headOut are reading/writing heads of the ring buffers */
// copying ring buffers content into fft input buffers
int headroom = windowSize - headIn;
std::copy_n(blockMain.get() + headIn, headroom, fftMain.get());
std::copy_n(blockMain.get(), headIn, fftMain.get() + headroom);
std::copy_n(blockSide.get() + headIn, headroom, fftSide.get());
std::copy_n(blockSide.get(), headIn, fftSide.get() + headroom);
// copying fft output buffers into ring buffer with an overlap-add
headroom = windowSizePadded - headOut;
juce::FloatVectorOperations::add(blockOut.get() + headOut, fftMain.get(), headroom);
juce::FloatVectorOperations::add(blockOut.get(), fftMain.get() + headroom, headOut);
I have no clue why those three specific HeapBlocks fail at freeing their memory and not the others, given they are managed in the same way. They don’t appear anywhere else in my code than what is being shown here but if you need more context please ask and I shall send what I can.

