diff --git a/README.md b/README.md index d8f0ef583f..d41dc862e5 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,19 @@ cargo miri test When using the above instructions, you may encounter a number of confusing compiler errors. +### "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace" + +You may see this when trying to get Miri to display a backtrace. By default, Miri +doesn't expose any environment to the program, so running +`RUST_BACKTRACE=1 cargo miri test` will not do what you expect. + +To get a backtrace, you need to disable isolation +[using `-Zmiri-disable-isolation`](#miri-flags): + +```sh +RUST_BACKTRACE=1 MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test +``` + #### "found possibly newer version of crate `std` which `` depends on" Your build directory may contain artifacts from an earlier build that have/have diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index 72c873b229..62fb9299c4 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -296,7 +296,7 @@ fn setup(subcommand: MiriCommand) { [dependencies.std] default_features = false # We support unwinding, so enable that panic runtime. -features = ["panic_unwind"] +features = ["panic_unwind", "backtrace"] [dependencies.test] "#, diff --git a/tests/run-pass/concurrency/simple.stderr b/tests/run-pass/concurrency/simple.stderr index e52d07cdc7..7060411278 100644 --- a/tests/run-pass/concurrency/simple.stderr +++ b/tests/run-pass/concurrency/simple.stderr @@ -1,4 +1,5 @@ warning: thread support is experimental. For example, Miri does not detect data races yet. thread '' panicked at 'Hello!', $DIR/simple.rs:54:9 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:64:9 diff --git a/tests/run-pass/panic/catch_panic.stderr b/tests/run-pass/panic/catch_panic.stderr index c31f54aac7..30c7767b56 100644 --- a/tests/run-pass/panic/catch_panic.stderr +++ b/tests/run-pass/panic/catch_panic.stderr @@ -1,4 +1,5 @@ thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:27 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Caught panic message (&str): Hello from panic: std thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:LL:26 Caught panic message (String): Hello from panic: 1 diff --git a/tests/run-pass/panic/concurrent-panic.stderr b/tests/run-pass/panic/concurrent-panic.stderr index d538efdb0e..eb5b5f59a0 100644 --- a/tests/run-pass/panic/concurrent-panic.stderr +++ b/tests/run-pass/panic/concurrent-panic.stderr @@ -3,6 +3,7 @@ warning: thread support is experimental. For example, Miri does not detect data Thread 1 starting, will block on mutex Thread 1 reported it has started thread '' panicked at 'panic in thread 2', $DIR/concurrent-panic.rs:65:13 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Thread 2 blocking on thread 1 Thread 2 reported it has started Unlocking mutex diff --git a/tests/run-pass/panic/div-by-zero-2.stderr b/tests/run-pass/panic/div-by-zero-2.stderr index d255811be2..60ff33c8bf 100644 --- a/tests/run-pass/panic/div-by-zero-2.stderr +++ b/tests/run-pass/panic/div-by-zero-2.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:4:14 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-lsh-neg.stderr b/tests/run-pass/panic/overflowing-lsh-neg.stderr index 04d98a0a2f..64959da0fa 100644 --- a/tests/run-pass/panic/overflowing-lsh-neg.stderr +++ b/tests/run-pass/panic/overflowing-lsh-neg.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:4:14 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-rsh-1.stderr b/tests/run-pass/panic/overflowing-rsh-1.stderr index a9a72f4622..bd8843f8d6 100644 --- a/tests/run-pass/panic/overflowing-rsh-1.stderr +++ b/tests/run-pass/panic/overflowing-rsh-1.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:4:14 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-rsh-2.stderr b/tests/run-pass/panic/overflowing-rsh-2.stderr index 24b6119456..c43090ea70 100644 --- a/tests/run-pass/panic/overflowing-rsh-2.stderr +++ b/tests/run-pass/panic/overflowing-rsh-2.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:5:14 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/panic1.rs b/tests/run-pass/panic/panic1.rs index 9d9ad28df5..4500c916ad 100644 --- a/tests/run-pass/panic/panic1.rs +++ b/tests/run-pass/panic/panic1.rs @@ -1,3 +1,9 @@ +// rustc-env: RUST_BACKTRACE=1 +// compile-flags: -Zmiri-disable-isolation +// normalize-stderr-test ".*/(rust|checkout)/library/" -> "RUSTLIB/" +// normalize-stderr-test "RUSTLIB/(.*):\d+:\d+ "-> "RUSTLIB/$1:LL:COL " +// normalize-stderr-test "::<.*>" -> "" + fn main() { std::panic!("panicking from libstd"); } diff --git a/tests/run-pass/panic/panic1.stderr b/tests/run-pass/panic/panic1.stderr index 954b8799a0..e06ec1b9ce 100644 --- a/tests/run-pass/panic/panic1.stderr +++ b/tests/run-pass/panic/panic1.stderr @@ -1 +1,23 @@ -thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:2:5 +thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:8:5 +stack backtrace: + 0: std::rt::begin_panic +RUSTLIB/std/src/panicking.rs:505:12 + 1: main + at $DIR/panic1.rs:8:5 + 2: >::call_once - shim(fn()) +RUSTLIB/core/src/ops/function.rs:227:5 + 3: std::rt::lang_start::{closure#0} +RUSTLIB/std/src/rt.rs:66:18 + 4: std::ops::function::impls::call_once +RUSTLIB/core/src/ops/function.rs:259:13 + 5: std::panicking::r#try::do_call +RUSTLIB/std/src/panicking.rs:381:40 + 6: std::panicking::r#try +RUSTLIB/std/src/panicking.rs:345:19 + 7: std::panic::catch_unwind +RUSTLIB/std/src/panic.rs:382:14 + 8: std::rt::lang_start_internal +RUSTLIB/std/src/rt.rs:51:25 + 9: std::rt::lang_start +RUSTLIB/std/src/rt.rs:65:5 +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/run-pass/panic/panic2.stderr b/tests/run-pass/panic/panic2.stderr index e90e3502cb..c0415b4e70 100644 --- a/tests/run-pass/panic/panic2.stderr +++ b/tests/run-pass/panic/panic2.stderr @@ -1 +1,2 @@ thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:2:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/panic3.stderr b/tests/run-pass/panic/panic3.stderr index 0a3c191b28..8aa8761aeb 100644 --- a/tests/run-pass/panic/panic3.stderr +++ b/tests/run-pass/panic/panic3.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:2:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/panic4.stderr b/tests/run-pass/panic/panic4.stderr index 946059b1e4..a71d25b74c 100644 --- a/tests/run-pass/panic/panic4.stderr +++ b/tests/run-pass/panic/panic4.stderr @@ -1 +1,2 @@ thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:2:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/transmute_fat2.stderr b/tests/run-pass/transmute_fat2.stderr index c8298a6c23..54ccdfb5e4 100644 --- a/tests/run-pass/transmute_fat2.stderr +++ b/tests/run-pass/transmute_fat2.stderr @@ -1 +1,2 @@ thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:15:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace