LLDB doesn’t stop on SIGABRT (assert) with x86 executable on Apple ARM

Hello. I am currently developing a C++ application for x86_64 using XCode, and I am experiencing the same problem as described in the following link. https://discourse.llvm.org/t/lldb-doesnt-stop-on-sigabrt-assert-with-x86-executable-on-apple-arm/69749/1

Due to this bug, when the application crashes, it is difficult to tell which source code caused the crash, and this is reducing our development efficiency.

How can this be fixed? Thank you in advance for your help.

Replies

How can this be fixed?

I recommend that you do what Jim suggested on that thread you referenced [1], namely file a bug.

Please post your bug number, just for the record.


In terms of workarounds, if you modify your assert macro to not use abort but rather invoke __builtin_trap(), that seems to make LLDB much happier.

If you can’t modify your assert macro then you could try something like this:

#include <stdio.h>
#include <stdlib.h>

static void myAbort(int sigNum) {
    __builtin_trap();
}

int main(int argc, const char * argv[]) {
    signal(SIGABRT, myAbort);
    fprintf(stderr, "Hello Cruel World!\n");
    abort();
    fprintf(stderr, "Goodbye Cruel World!\n");
    return 0;
}

This does really weird stuff when you run it directly [2], but it seems to yield reasonable results when debugging with LLDB.

btw I’m testing on macOS 14.0 with Xcode 15.0. YMMV on other configs.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] https://discourse.llvm.org/t/lldb-doesnt-stop-on-sigabrt-assert-with-x86-executable-on-apple-arm/69749/1

[2] I won’t hold that against Rosetta. Honestly, I’m in awe of its ability to make any of this stuff work.

Thanks for the reply.

I recommend that you do what Jim suggested on that thread you referenced [1], namely file a bug. Please post your bug number, just for the record.

I have immediately reported the bug. Here is the number. FB13382646

In terms of workarounds, if you modify your assert macro to not use abort but rather invoke __builtin_trap(), that seems to make LLDB much happier.

I tried __builtin_trap. As a result, LLDB stopped when the app crashed. Thank you very much.