Skip to content

Commit db97444

Browse files
committed
when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var isolation
1 parent 38104f3 commit db97444

23 files changed

+29
-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/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
|
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)