Inexplicable Crash with Xcode latest M1 build

When building an M1 debug build I’m getting the most bizarre crash.

    DBG (processor.compressor.getNumBands()); // does not crash
    decltype (processor.compressor)* cp{ &processor.compressor };
    DBG (cp->getNumBands()); // crashes here

I get a EXC_BAD_ACCESS (code=1, address=0x101d85e30) on the second DBG, which is essentially identical to the first one!?

The two things even have the same memory address in the debugger.

p &processor.compressor
(MultibandDrummondCompressor2<1> *) $0 = 0x0000000143840890
(lldb) p cp
(MultibandDrummondCompressor2<1> *) $1 = 0x0000000143840890

Any clues…

Does it crash with Address Sanitizer enabled?

I didn’t get an address santiizer report when it crashes with it enabled.


Presumably this is the line that crashes.

Why would it load one thing into x8 and then immediately another. What ARM trickery am I missing here?

    0x1020b44d0 <+232>: ldr    x8, [x0]
->  0x1020b44d4 <+236>: ldr    x8, [x8, #0x18]

Works fine in Rosetta :slight_smile:

Have you tried thread sanitizer?

I’ll give it a whirl. But I don’t think it’s a threading issue, the object being referenced is completely static and constructed on startup…

And the crash is 100% reliable!

edit: Thread Sanitizer says nothing.

Well the difference is I think that the second call is actually a virtual function call, whereas the first call, even in the debug build doesn’t go through the vtable.