rust/tests/ui/panics
bors f437c86ef8 Auto merge of #143613 - Enselic:panic-abort-uwtables, r=petrochenkov
Fix backtraces with `-C panic=abort` on linux; emit unwind tables by default

The linux backtrace unwinder relies on unwind tables to work properly, and generating and printing a backtrace is done by for example the default panic hook.

Begin emitting unwind tables by default again with `-C panic=abort` (see history below) so that backtraces work.

Closes https://github.com/rust-lang/rust/issues/81902 which is **regression-from-stable-to-stable**
Closes https://github.com/rust-lang/rust/issues/94815

### History

Backtraces with `-C panic=abort` used to work in Rust 1.22 but broke in Rust 1.23, because in 1.23 we stopped emitting unwind tables with `-C panic=abort` (see https://github.com/rust-lang/rust/pull/45031 and https://github.com/rust-lang/rust/issues/81902#issuecomment-3046487084).

In 1.45 a workaround in the form of `-C force-unwind-tables=yes` was added (see https://github.com/rust-lang/rust/pull/69984).

`-C panic=abort` was added in [Rust 1.10](https://blog.rust-lang.org/2016/07/07/Rust-1.10/#what-s-in-1-10-stable) and the motivation was binary size and compile time. But given how confusing that behavior has turned out to be, it is better to make binary size optimization opt-in with `-C force-unwind-tables=no` rather than default since the current default breaks backtraces.

Besides, if binary size is a primary concern, there are many other tricks that can be used that has a higher impact.

# Release Note Entry Draft:

## Compatibility Notes

* [Fix backtraces with `-C panic=abort` on Linux by generating unwind tables by default](https://github.com/rust-lang/rust/pull/143613). Build with `-C force-unwind-tables=no` to keep omitting unwind tables.

try-job: aarch64-apple
try-job: armhf-gnu
try-job: aarch64-msvc-1
2025-10-03 15:02:37 +00:00
..
abort-on-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
args-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
catch-unwind-bang.rs Move tests from /ui directory 2025-04-29 18:19:26 +02:00
default-backtrace-ice.rs compiletest: Support matching on non-json lines in compiler output 2025-05-04 18:27:45 +03:00
default-backtrace-ice.stderr compiletest: Support matching on non-json lines in compiler output 2025-05-04 18:27:45 +03:00
doublepanic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
explicit-panic-msg.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
explicit-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
fmt-only-once.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
fmt-only-once.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
fmt-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
issue-47429-short-backtraces.rs ci: Begin running ui tests with rust.debuginfo-level-tests=1 2025-08-22 17:27:47 +02:00
issue-47429-short-backtraces.run.stderr ci: Begin running ui tests with rust.debuginfo-level-tests=1 2025-08-22 17:27:47 +02:00
location-detail-panic-no-column.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-detail-panic-no-column.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
location-detail-panic-no-file.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-detail-panic-no-file.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
location-detail-panic-no-line.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-detail-panic-no-line.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
location-detail-panic-no-location-info.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-detail-panic-no-location-info.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
location-detail-unwrap-multiline.rs Add a missing colon at the end of the expected panic message in location-detail-unwrap-multiline.rs 2025-06-17 12:24:44 -07:00
location-detail-unwrap-no-file.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
location-detail-unwrap-no-file.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
main-panic.rs Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
nested_panic_caught.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
oom-panic-unwind.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-2021.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
panic-2021.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
panic-abort-backtrace-without-debuginfo.rs Fix backtraces with -C panic=abort on linux; emit unwind tables by default 2025-10-02 19:46:41 +02:00
panic-arg.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-during-display-formatting.rs cleaned up some tests 2025-07-05 03:46:08 +05:00
panic-handler-chain-update-hook.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-handler-chain.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-handler-closures.rs cleaned up some tests 2025-07-05 03:46:08 +05:00
panic-handler-flail-wildly.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-handler-set-twice.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-in-cleanup.rs tests: Require run-fail ui tests to have an exit code (SIGABRT not ok) 2025-07-19 18:44:07 +02:00
panic-in-cleanup.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-in-dtor-drops-fields.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-in-ffi.rs tests: Require run-fail ui tests to have an exit code (SIGABRT not ok) 2025-07-19 18:44:07 +02:00
panic-in-ffi.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-in-message-fmt.rs tests: Require run-fail ui tests to have an exit code (SIGABRT not ok) 2025-07-19 18:44:07 +02:00
panic-in-message-fmt.run.stderr panic-in-panic-hook: formatting a message that's just a string is risk-free 2024-03-24 10:29:44 +01:00
panic-macro-any-wrapped.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-macro-any.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-macro-explicit.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-macro-fmt.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-macro-owned.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-macro-static.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-main.rs tests: Require run-fail ui tests to have an exit code (SIGABRT not ok) 2025-07-19 18:44:07 +02:00
panic-parens.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-recover-propagate.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
panic-set-handler.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
panic-set-unset-handler.rs Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-short-backtrace-windows-x86_64.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
panic-short-backtrace-windows-x86_64.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-take-handler-nop.rs Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-task-name-none.rs Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic-task-name-owned.rs Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
result-get-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
runtime-switch.rs ci: Begin running ui tests with rust.debuginfo-level-tests=1 2025-08-22 17:27:47 +02:00
runtime-switch.run.stderr ci: Begin running ui tests with rust.debuginfo-level-tests=1 2025-08-22 17:27:47 +02:00
rvalue-cleanup-during-box-panic.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
short-ice-remove-middle-frames-2.rs tests: remove redundant //@ ignore-{wasm,wasm32,emscripten} 2025-02-03 22:27:17 +08:00
short-ice-remove-middle-frames-2.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
short-ice-remove-middle-frames.rs tests: remove redundant //@ ignore-{wasm,wasm32,emscripten} 2025-02-03 22:27:17 +08:00
short-ice-remove-middle-frames.run.stderr Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
test-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
test-should-fail-bad-message.rs Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
test-should-panic-bad-message.rs Update test directives for wasm32-wasip1 2024-03-11 09:36:35 -07:00
test-should-panic-no-message.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
unique-panic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unwind-force-no-unwind-tables.rs Ignore more failing ui tests for GCC backend 2025-09-26 15:33:48 +02:00
while-body-panics.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00
while-panic.rs tests: use needs-subprocess instead of ignore-{wasm32,emscripten,sgx} 2025-01-23 20:51:29 +08:00