-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Panic backtrace doesn't traverse ffi code with panic=abort #88275
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
The cause is given in the
|
Triage: Since the @glandium Do you happen to remember where you looked for documentation regarding this? That place is a good candidate for improving the docs. |
I'm not sure where I looked back then. I was probably just expecting things to work and didn't try to find the information (my bad, I guess). But if I were, I would probably look at std::panic (BTW, the std::panic module doc should probably say that plenty of information is in the doc for the macro ; also the std::panic macro doc doesn't mention panic=abort). I guess the book's chapter about panics would be a good place too (https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html) |
I'm confused. Isn't the entire point of panic=abort to not unwind and thus not produce a proper backtrace (in exchange for a smaller binary)? |
Capturing a stack trace is different from unwinding the stack, calling drop glue in every frame, and possibly stopping at a As for the original issue, yeah it would be good to document the importance of -C force-unwind-tables somewhere in the std docs, such as the std::panic module or the panic macro. |
@hanna-kruppe thanks for the clear and detailed explanation. Issue #94815 suggests just forcing that "-C force-unwind-tables" flag, which seems like a good idea, in which case the docs would not need to talk about this... |
I also think it would be good to change the default on some targets at least, but it would still be nice to explain the implications of not having the Tables somewhere. Note that some targets already default to or require such tables (eg, 64-bit windows) but I wouldn’t want to assume that all targets will necessarily default to them. Especially once build-std is stabilized and users can modify which flags the sysroot crates are compiled with. |
I tried this code:
Cargo.toml
:build.rs
:foo.c
:src/main.rs
:I expected to see this happen: the panic backtrace would traverse the ffi code, like it does without panic=abort.
Instead, this happened: the panic backtrace stops at
do_rust_panic
:Without panic=abort:
Meta
rustc --version --verbose
:Also reproducible with nightly:
I tried tweaking the FFI build flags, adding combinations of
-fno-omit-frame-pointer
,-funwind-tables
and-g
, and none of them changed anything.The text was updated successfully, but these errors were encountered: