Crash in AAX with std::array

Not a JUCE class, but for some reason I’m getting a crash in AAX (but not AU or VST3, running on my Intel Macbook Pro under OS X 10.15) with std::array. I have defined the array like this:

std::array<short,4*BufferSize> outBuffer;

(where BufferSize is 65536, so that there are 262144 elements in the array).

But when debugging, it crashes while filling that buffer from an AudioBlock. Notice the Expressions in the debug window below. The location in the array that I am trying to write to at the time it throws an exception says “invalid expression”, even though other locations in the array, including the very last allocated location, all show their values (and can be written to) with no problems.

I’ve tried using pointers to the data (as you can see in the commented-out code), as well as indexed access, but I get the same crash. As a test, to see if I’m overwriting memory before it gets to this point, I stopped the debugger just after defining that array, and I get exactly the same output in the debugger window. It says that outBuffer[131265] is an invalid expression. How can that be???

That’s a lot on the stack.
Stack size is usually 1MB so in your case you already take 4 * 65536 * 2 (short is 2 byte) ~= 500Ko

recipe for disaster imho
unless you don’t want to allocate on heap, use vector

Ah, hadn’t considered that. Making them members of the class instead of local variables fixed it.