Skip to content

Commit ea1b92d

Browse files
Rollup merge of rust-lang#124116 - RalfJung:miri-rust-backtrace, r=Nilstrieb
when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation Fixes rust-lang/miri#2855
2 parents 0744cb0 + 3e63398 commit ea1b92d

32 files changed

+38
-0
lines changed

library/std/src/panicking.rs

+7
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ fn default_hook(info: &PanicInfo<'_>) {
277277
"note: run with `RUST_BACKTRACE=1` environment variable to display a \
278278
backtrace"
279279
);
280+
if cfg!(miri) {
281+
let _ = writeln!(
282+
err,
283+
"note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` \
284+
for the environment variable to have an effect"
285+
);
286+
}
280287
}
281288
}
282289
// If backtraces aren't supported or are forced-off, do nothing.

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
56
--> $DIR/exported_symbol_bad_unwind1.rs:LL:CC
67
|

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
56
panic in a function that cannot unwind
67
stack backtrace:

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
56
panic in a function that cannot unwind
67
stack backtrace:

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/exported_symbol_bad_unwind2.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
56
--> $DIR/exported_symbol_bad_unwind2.rs:LL:CC
67
|

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/return_pointer_on_unwind.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
56
--> $DIR/return_pointer_on_unwind.rs:LL:CC
67
|

src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
22
aborted execution: attempted to instantiate uninhabited type `!`
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread caused non-unwinding panic. aborting.
56
error: abnormal termination: the program aborted execution
67
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC

src/tools/miri/tests/fail/intrinsics/zero_fn_ptr.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
22
aborted execution: attempted to zero-initialize type `fn()`, which is invalid
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread caused non-unwinding panic. aborting.
56
error: abnormal termination: the program aborted execution
67
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC

src/tools/miri/tests/fail/panic/bad_unwind.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/bad_unwind.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
56
--> $DIR/bad_unwind.rs:LL:CC
67
|

src/tools/miri/tests/fail/panic/double_panic.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
22
first
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
56
second
67
stack backtrace:

src/tools/miri/tests/fail/panic/panic_abort1.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/panic_abort1.rs:LL:CC:
22
panicking from libstd
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: abnormal termination: the program aborted execution
56
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC
67
|

src/tools/miri/tests/fail/panic/panic_abort2.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/panic_abort2.rs:LL:CC:
22
42-panicking from libstd
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: abnormal termination: the program aborted execution
56
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC
67
|

src/tools/miri/tests/fail/panic/panic_abort3.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/panic_abort3.rs:LL:CC:
22
panicking from libcore
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: abnormal termination: the program aborted execution
56
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC
67
|

src/tools/miri/tests/fail/panic/panic_abort4.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/panic_abort4.rs:LL:CC:
22
42-panicking from libcore
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
error: abnormal termination: the program aborted execution
56
--> RUSTLIB/panic_abort/src/lib.rs:LL:CC
67
|

src/tools/miri/tests/fail/terminate-terminator.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ warning: You have explicitly enabled MIR optimizations, overriding Miri's defaul
33
thread 'main' panicked at $DIR/terminate-terminator.rs:LL:CC:
44
explicit panic
55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
6+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
67
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
78
panic in a function that cannot unwind
89
stack backtrace:

src/tools/miri/tests/fail/unwind-action-terminate.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/unwind-action-terminate.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
56
panic in a function that cannot unwind
67
stack backtrace:
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/div-by-zero-2.rs:LL:CC:
22
attempt to divide by zero
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

src/tools/miri/tests/panic/function_calls/exported_symbol_good_unwind.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
22
explicit panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
56
explicit panic
67
thread 'main' panicked at $DIR/exported_symbol_good_unwind.rs:LL:CC:
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/oob_subslice.rs:LL:CC:
22
range end index 5 out of range for slice of length 4
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/overflowing-lsh-neg.rs:LL:CC:
22
attempt to shift left with overflow
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/overflowing-rsh-1.rs:LL:CC:
22
attempt to shift right with overflow
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/overflowing-rsh-2.rs:LL:CC:
22
attempt to shift right with overflow
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/panic2.rs:LL:CC:
22
42-panicking from libstd
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/panic3.rs:LL:CC:
22
panicking from libcore
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/panic4.rs:LL:CC:
22
42-panicking from libcore
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/transmute_fat2.rs:LL:CC:
22
index out of bounds: the len is 0 but the index is 0
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/unsupported_foreign_function.rs:LL:CC:
22
unsupported Miri functionality: can't call foreign function `foo` on $OS
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
thread 'main' panicked at $DIR/unsupported_syscall.rs:LL:CC:
22
unsupported Miri functionality: can't execute syscall with ID 0
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect

src/tools/miri/tests/pass/panic/catch_panic.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
22
Hello from std::panic
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
Caught panic message (&str): Hello from std::panic
56
thread 'main' panicked at $DIR/catch_panic.rs:LL:CC:
67
Hello from std::panic: 1

src/tools/miri/tests/pass/panic/concurrent-panic.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Thread 1 reported it has started
33
thread '<unnamed>' panicked at $DIR/concurrent-panic.rs:LL:CC:
44
panic in thread 2
55
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
6+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
67
Thread 2 blocking on thread 1
78
Thread 2 reported it has started
89
Unlocking mutex
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
22
once
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'main' panicked at $DIR/nested_panic_caught.rs:LL:CC:
56
twice
67
stack backtrace:
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
thread '<unnamed>' panicked at $DIR/thread_panic.rs:LL:CC:
22
Hello!
33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4+
note: in Miri, you may have to set `-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
45
thread 'childthread' panicked at $DIR/thread_panic.rs:LL:CC:
56
Hello, world!

0 commit comments

Comments
 (0)