Skip to content

Commit 1ccd96f

Browse files
committed
Print thread ID in panic message if thread name is unknown
`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
1 parent ad6ffe9 commit 1ccd96f

36 files changed

+63
-57
lines changed

tests/fail/function_calls/exported_symbol_bad_unwind1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind1.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind1.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
66

7-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
7+
thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
88
panic in a function that cannot unwind
99
stack backtrace:
1010
thread caused non-unwinding panic. aborting.

tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
66

7-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
7+
thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
88
panic in a function that cannot unwind
99
stack backtrace:
1010
thread caused non-unwinding panic. aborting.

tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

tests/fail/function_calls/return_pointer_on_unwind.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

tests/fail/panic/abort_unwind.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
thread 'main' panicked at tests/fail/panic/abort_unwind.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/panic/abort_unwind.rs:LL:CC:
33
PANIC!!!
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
66

7-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
7+
thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
88
panic in a function that cannot unwind
99
stack backtrace:
1010
thread caused non-unwinding panic. aborting.

tests/fail/panic/bad_unwind.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/panic/bad_unwind.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/panic/bad_unwind.rs:LL:CC:
33
explicit panic
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

tests/fail/panic/double_panic.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
thread 'main' panicked at tests/fail/panic/double_panic.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/panic/double_panic.rs:LL:CC:
33
first
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
66

7-
thread 'main' panicked at tests/fail/panic/double_panic.rs:LL:CC:
7+
thread 'main' ($TID) panicked at tests/fail/panic/double_panic.rs:LL:CC:
88
second
99
stack backtrace:
1010

11-
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
11+
thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
1212
panic in a destructor during cleanup
1313
thread caused non-unwinding panic. aborting.
1414
error: abnormal termination: the program aborted execution

tests/fail/panic/panic_abort1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/panic/panic_abort1.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/panic/panic_abort1.rs:LL:CC:
33
panicking from libstd
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

tests/fail/panic/panic_abort2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
thread 'main' panicked at tests/fail/panic/panic_abort2.rs:LL:CC:
2+
thread 'main' ($TID) panicked at tests/fail/panic/panic_abort2.rs:LL:CC:
33
42-panicking from libstd
44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
55
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

0 commit comments

Comments
 (0)