diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 996164b93e..b74444fbc6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contribution Guide -If you want to hack on miri yourself, great! Here are some resources you might +If you want to hack on Miri yourself, great! Here are some resources you might find useful. ## Getting started @@ -89,6 +89,20 @@ MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/run-pa In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an evaluation error was originally raised. +#### UI testing + +We use ui-testing in Miri, meaning we generate `.stderr` and `.stdout` files for the output +produced by Miri. You can use `./miri bless` to automatically (re)generate these files when +you add new tests or change how Miri presents certain output. + +Note that when you also use `MIRIFLAGS` to change optimizations and similar, the ui output +will change in unexpected ways. In order to still be able +to run the other checks while ignoring the ui output, use `MIRI_SKIP_UI_CHECKS=1 ./miri test`. + +For more info on how to configure ui tests see [the documentation on the ui test crate][ui_test] + +[ui_test]: ui_test/README.md + ### Testing `cargo miri` Working with the driver directly gives you full control, but you also lose all @@ -183,7 +197,7 @@ A big part of the Miri driver lives in rustc, so working on Miri will sometimes require using a locally built rustc. The bug you want to fix may actually be on the rustc side, or you just need to get more detailed trace of the execution than what is possible with release builds -- in both cases, you should develop -miri against a rustc you compiled yourself, with debug assertions (and hence +Miri against a rustc you compiled yourself, with debug assertions (and hence tracing) enabled. The setup for a local rustc works as follows: @@ -191,7 +205,7 @@ The setup for a local rustc works as follows: # Clone the rust-lang/rust repo. git clone https://github.com/rust-lang/rust rustc cd rustc -# Create a config.toml with defaults for working on miri. +# Create a config.toml with defaults for working on Miri. ./x.py setup compiler # Now edit `config.toml` and under `[rust]` set `debug-assertions = true`. diff --git a/Cargo.lock b/Cargo.lock index 35e45800c0..5377f9420b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,10 +12,13 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.51" +name = "ansi_term" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] [[package]] name = "atty" @@ -28,6 +31,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "bitflags" version = "1.3.2" @@ -52,87 +61,101 @@ dependencies = [ ] [[package]] -name = "compiletest_rs" -version = "0.7.1" +name = "crossbeam" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29843cb8d351febf86557681d049d1e1652b81a086a190fa1173c07fd17fbf83" +checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845" dependencies = [ - "diff", - "filetime", - "getopts", - "lazy_static", - "libc", - "log", - "miow", - "regex", - "rustfix", - "serde", - "serde_derive", - "serde_json", - "tempfile", - "tester", - "winapi", + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", ] [[package]] -name = "diff" -version = "0.1.12" +name = "crossbeam-channel" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] [[package]] -name = "dirs-next" -version = "2.0.0" +name = "crossbeam-deque" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if", - "dirs-sys-next", + "crossbeam-epoch", + "crossbeam-utils", ] [[package]] -name = "dirs-sys-next" -version = "0.1.2" +name = "crossbeam-epoch" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ - "libc", - "redox_users", - "winapi", + "autocfg", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", ] [[package]] -name = "env_logger" -version = "0.9.0" +name = "crossbeam-queue" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2" dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", + "cfg-if", + "crossbeam-utils", ] [[package]] -name = "filetime" -version = "0.2.15" +name = "crossbeam-utils" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if", - "libc", - "redox_syscall", - "winapi", + "lazy_static", ] [[package]] -name = "getopts" -version = "0.2.21" +name = "ctor" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" dependencies = [ - "unicode-width", + "quote", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "env_logger" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", ] [[package]] @@ -170,12 +193,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" - [[package]] name = "lazy_static" version = "1.4.0" @@ -236,12 +253,12 @@ dependencies = [ ] [[package]] -name = "miow" -version = "0.3.7" +name = "memoffset" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "winapi", + "autocfg", ] [[package]] @@ -249,27 +266,27 @@ name = "miri" version = "0.1.0" dependencies = [ "colored", - "compiletest_rs", "env_logger", "getrandom", + "lazy_static", "libc", "log", "measureme", "rand", + "regex", "rustc-workspace-hack", - "rustc_version", "shell-escape", "smallvec", + "ui_test", ] [[package]] -name = "num_cpus" -version = "1.13.0" +name = "output_vt100" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" dependencies = [ - "hermit-abi", - "libc", + "winapi", ] [[package]] @@ -312,20 +329,32 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +[[package]] +name = "pretty_assertions" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563" +dependencies = [ + "ansi_term", + "ctor", + "diff", + "output_vt100", +] + [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" dependencies = [ "proc-macro2", ] @@ -379,21 +408,11 @@ dependencies = [ "bitflags", ] -[[package]] -name = "redox_users" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" -dependencies = [ - "getrandom", - "redox_syscall", -] - [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", @@ -406,15 +425,6 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rustc-hash" version = "1.1.0" @@ -436,30 +446,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustfix" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c50b74badcddeb8f7652fa8323ce440b95286f8e4b64ebfd871c609672704e" -dependencies = [ - "anyhow", - "log", - "serde", - "serde_json", -] - -[[package]] -name = "rustversion" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" - -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - [[package]] name = "scopeguard" version = "1.1.0" @@ -468,40 +454,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" - -[[package]] -name = "serde" -version = "1.0.131" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ad69dfbd3e45369132cc64e6748c2d65cdfb001a2b1c232d128b4ad60561c1" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.131" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b710a83c4e0dff6a3d511946b95274ad9ca9e5d3ae497b63fda866ac955358d2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.73" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcbd0344bc6533bc7ec56df11d42fb70f1b912351c0825ccb7211b59d8af7cf5" -dependencies = [ - "itoa", - "ryu", - "serde", -] +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd" [[package]] name = "shell-escape" @@ -517,38 +472,13 @@ checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "syn" -version = "1.0.82" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" dependencies = [ "proc-macro2", "quote", - "unicode-xid", -] - -[[package]] -name = "tempfile" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", + "unicode-ident", ] [[package]] @@ -561,29 +491,22 @@ dependencies = [ ] [[package]] -name = "tester" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0639d10d8f4615f223a57275cf40f9bdb7cfbb806bcb7f7cc56e3beb55a576eb" +name = "ui_test" +version = "0.1.0" dependencies = [ - "cfg-if", - "getopts", - "libc", - "num_cpus", - "term", + "colored", + "crossbeam", + "lazy_static", + "pretty_assertions", + "regex", + "rustc_version", ] [[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - -[[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" [[package]] name = "wasi" diff --git a/Cargo.toml b/Cargo.toml index 6d65ab6e1e..cf6f4c8b2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,9 +37,10 @@ measureme = "9.1.2" libc = "0.2" [dev-dependencies] -compiletest_rs = { version = "0.7", features = ["tmp"] } -rustc_version = "0.4" colored = "2" +ui_test = { path = "ui_test" } +regex = "1.5.5" +lazy_static = "1.4.0" [package.metadata.rust-analyzer] # This crate uses #[feature(rustc_private)]. diff --git a/README.md b/README.md index 0f6c5007ba..afee8a8bfa 100644 --- a/README.md +++ b/README.md @@ -328,7 +328,7 @@ to Miri failing to detect cases of undefined behavior in a program. using the tools in the repository https://github.com/rust-lang/measureme. * `-Zmiri-mute-stdout-stderr` silently ignores all writes to stdout and stderr, but reports to the program that it did actually write. This is useful when you - are not interested in the actual program's output, but only want to see miri's + are not interested in the actual program's output, but only want to see Miri's errors and warnings. * `-Zmiri-panic-on-unsupported` will makes some forms of unsupported functionality, such as FFI and unsupported syscalls, panic within the context of the emulated @@ -412,6 +412,11 @@ Moreover, Miri recognizes some environment variables: * `MIRI_TEST_TARGET` (recognized by the test suite) indicates which target architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same purpose. +* `MIRI_BLESS` (recognized by the test suite) overwrite all `stderr` and `stdout` files + instead of checking whether the output matches. +* `MIRI_SKIP_UI_CHECKS` (recognized by the test suite) don't check whether the + `stderr` or `stdout` files match the actual output. Useful for the rustc test suite + which has subtle differences that we don't care about. The following environment variables are *internal* and must not be used by anyone but Miri itself. They are used to communicate between different Miri @@ -519,15 +524,15 @@ GitHub or use the [Miri stream on the Rust Zulip][zulip]. This project began as part of an undergraduate research course in 2015 by @solson at the [University of Saskatchewan][usask]. There are [slides] and a -[report] available from that project. In 2016, @oli-obk joined to prepare miri +[report] available from that project. In 2016, @oli-obk joined to prepare Miri for eventually being used as const evaluator in the Rust compiler itself (basically, for `const` and `static` stuff), replacing the old evaluator that worked directly on the AST. In 2017, @RalfJung did an internship with Mozilla -and began developing miri towards a tool for detecting undefined behavior, and -also using miri as a way to explore the consequences of various possible -definitions for undefined behavior in Rust. @oli-obk's move of the miri engine +and began developing Miri towards a tool for detecting undefined behavior, and +also using Miri as a way to explore the consequences of various possible +definitions for undefined behavior in Rust. @oli-obk's move of the Miri engine into the compiler finally came to completion in early 2018. Meanwhile, later -that year, @RalfJung did a second internship, developing miri further with +that year, @RalfJung did a second internship, developing Miri further with support for checking basic type invariants and verifying that references are used according to their aliasing restrictions. diff --git a/cargo-miri/bin.rs b/cargo-miri/bin.rs index 373c63647c..e08cb8c88c 100644 --- a/cargo-miri/bin.rs +++ b/cargo-miri/bin.rs @@ -461,7 +461,12 @@ path = "lib.rs" command.env_remove("RUSTFLAGS"); // Disable debug assertions in the standard library -- Miri is already slow enough. // But keep the overflow checks, they are cheap. - command.env("RUSTFLAGS", "-Cdebug-assertions=off -Coverflow-checks=on"); + // Also remap the current directory to something that is stable across different + // machines. Otherwise ui output would contain the current directory. + command.env( + "RUSTFLAGS", + "-Cdebug-assertions=off -Coverflow-checks=on -Zremap-cwd-prefix=rustc_src", + ); // Finally run it! if command.status().expect("failed to run xargo").success().not() { show_error(format!("failed to run xargo")); diff --git a/ci.sh b/ci.sh index c19aceb641..d435e0e2a2 100755 --- a/ci.sh +++ b/ci.sh @@ -24,7 +24,8 @@ function run_tests { if [ -z "${MIRI_TEST_TARGET+exists}" ]; then # Only for host architecture: tests with optimizations (`-O` is what cargo passes, but crank MIR # optimizations up all the way). - MIRIFLAGS="-O -Zmir-opt-level=4" ./miri test --locked + # Optimizations change diagnostics (mostly backtraces), so we don't check them + MIRIFLAGS="-O -Zmir-opt-level=4" MIRI_SKIP_UI_CHECKS=1 ./miri test --locked fi # On Windows, there is always "python", not "python3" or "python2". diff --git a/miri b/miri index 56ae119cd1..6a809b7435 100755 --- a/miri +++ b/miri @@ -123,10 +123,15 @@ build|build-debug) cargo build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml "$@" cargo build $CARGO_BUILD_FLAGS --manifest-path "$MIRIDIR"/cargo-miri/Cargo.toml "$@" ;; -test|test-debug) +test|test-debug|bless|bless-debug) # First build and get a sysroot. cargo build $CARGO_BUILD_FLAGS find_sysroot + case "$COMMAND" in + bless|bless-debug) + export MIRI_BLESS="Gesundheit" + ;; + esac # Then test, and let caller control flags. # Only in root project as `cargo-miri` has no tests. exec cargo test $CARGO_BUILD_FLAGS "$@" diff --git a/src/machine.rs b/src/machine.rs index c5c884e8d7..249b578b12 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -583,7 +583,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> { if let Some(&ptr) = ecx.machine.extern_statics.get(&link_name) { Ok(ptr) } else { - throw_unsup_format!("`extern` static {:?} is not supported by Miri", def_id) + throw_unsup_format!( + "`extern` static `{}` from crate `{}` is not supported by Miri", + ecx.tcx.def_path_str(def_id), + ecx.tcx.crate_name(def_id.krate), + ) } } diff --git a/tests/compile-fail/abort-terminator.stderr b/tests/compile-fail/abort-terminator.stderr new file mode 100644 index 0000000000..76501ca074 --- /dev/null +++ b/tests/compile-fail/abort-terminator.stderr @@ -0,0 +1,19 @@ +thread 'main' panicked at 'explicit panic', $DIR/abort-terminator.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + --> $DIR/abort-terminator.rs:LL:CC + | +LL | extern "C" fn panic_abort() { panic!() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the program aborted execution + | + = note: inside `panic_abort` at $DIR/abort-terminator.rs:LL:CC +note: inside `main` at $DIR/abort-terminator.rs:LL:CC + --> $DIR/abort-terminator.rs:LL:CC + | +LL | panic_abort(); + | ^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/deallocate-bad-alignment.stderr b/tests/compile-fail/alloc/deallocate-bad-alignment.stderr new file mode 100644 index 0000000000..e03704b118 --- /dev/null +++ b/tests/compile-fail/alloc/deallocate-bad-alignment.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC + --> $DIR/deallocate-bad-alignment.rs:LL:CC + | +LL | dealloc(x, Layout::from_size_align_unchecked(1, 2)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/deallocate-bad-size.stderr b/tests/compile-fail/alloc/deallocate-bad-size.stderr new file mode 100644 index 0000000000..3ab15094da --- /dev/null +++ b/tests/compile-fail/alloc/deallocate-bad-size.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC + --> $DIR/deallocate-bad-size.rs:LL:CC + | +LL | dealloc(x, Layout::from_size_align_unchecked(2, 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/deallocate-twice.stderr b/tests/compile-fail/alloc/deallocate-twice.stderr new file mode 100644 index 0000000000..dfd14c3978 --- /dev/null +++ b/tests/compile-fail/alloc/deallocate-twice.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/deallocate-twice.rs:LL:CC + --> $DIR/deallocate-twice.rs:LL:CC + | +LL | dealloc(x, Layout::from_size_align_unchecked(1, 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/global_system_mixup.rs b/tests/compile-fail/alloc/global_system_mixup.rs index afe9d5cc82..3f58de4d6f 100644 --- a/tests/compile-fail/alloc/global_system_mixup.rs +++ b/tests/compile-fail/alloc/global_system_mixup.rs @@ -2,6 +2,8 @@ // (even when the default `Global` uses `System`). // error-pattern: which is Rust heap memory, using +// normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation" + #![feature(allocator_api, slice_ptr_get)] use std::alloc::{Allocator, Global, System, Layout}; diff --git a/tests/compile-fail/alloc/global_system_mixup.stderr b/tests/compile-fail/alloc/global_system_mixup.stderr new file mode 100644 index 0000000000..93598be134 --- /dev/null +++ b/tests/compile-fail/alloc/global_system_mixup.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: deallocating ALLOC, which is Rust heap memory, using PLATFORM heap deallocation operation + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::sys::PLATFORM::alloc::::dealloc` at rustc_src/src/sys/PLATFORM/alloc.rs:LL:CC + = note: inside `::deallocate` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/global_system_mixup.rs:LL:CC + --> $DIR/global_system_mixup.rs:LL:CC + | +LL | unsafe { System.deallocate(ptr, l); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/no_global_allocator.stderr b/tests/compile-fail/alloc/no_global_allocator.stderr new file mode 100644 index 0000000000..2a9840ee83 --- /dev/null +++ b/tests/compile-fail/alloc/no_global_allocator.stderr @@ -0,0 +1,12 @@ +error: unsupported operation: can't call foreign function: __rust_alloc + --> $DIR/no_global_allocator.rs:LL:CC + | +LL | __rust_alloc(1, 1); + | ^^^^^^^^^^^^^^^^^^ can't call foreign function: __rust_alloc + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `start` at $DIR/no_global_allocator.rs:LL:CC + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/reallocate-bad-size.stderr b/tests/compile-fail/alloc/reallocate-bad-size.stderr new file mode 100644 index 0000000000..f2692b1c34 --- /dev/null +++ b/tests/compile-fail/alloc/reallocate-bad-size.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::realloc` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/reallocate-bad-size.rs:LL:CC + --> $DIR/reallocate-bad-size.rs:LL:CC + | +LL | let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/reallocate-change-alloc.stderr b/tests/compile-fail/alloc/reallocate-change-alloc.stderr new file mode 100644 index 0000000000..d400931379 --- /dev/null +++ b/tests/compile-fail/alloc/reallocate-change-alloc.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/reallocate-change-alloc.rs:LL:CC + | +LL | let _z = *x; + | ^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/reallocate-change-alloc.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/reallocate-dangling.stderr b/tests/compile-fail/alloc/reallocate-dangling.stderr new file mode 100644 index 0000000000..d813fb0db9 --- /dev/null +++ b/tests/compile-fail/alloc/reallocate-dangling.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::realloc` at rustc_src/src/alloc.rs:LL:CC +note: inside `main` at $DIR/reallocate-dangling.rs:LL:CC + --> $DIR/reallocate-dangling.rs:LL:CC + | +LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/alloc/stack_free.stderr b/tests/compile-fail/alloc/stack_free.stderr new file mode 100644 index 0000000000..9df85d6eab --- /dev/null +++ b/tests/compile-fail/alloc/stack_free.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC + = note: inside `::deallocate` at rustc_src/src/alloc.rs:LL:CC + = note: inside `alloc::alloc::box_free::` at rustc_src/src/alloc.rs:LL:CC + = note: inside `std::ptr::drop_in_place::> - shim(Some(std::boxed::Box))` at rustc_src/src/ptr/mod.rs:LL:CC + = note: inside `std::mem::drop::>` at rustc_src/src/mem/mod.rs:LL:CC +note: inside `main` at $DIR/stack_free.rs:LL:CC + --> $DIR/stack_free.rs:LL:CC + | +LL | drop(bad_box); + | ^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-decl.stderr b/tests/compile-fail/backtrace/bad-backtrace-decl.stderr new file mode 100644 index 0000000000..007ef96f72 --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-decl.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: bad declaration of miri_resolve_frame - should return a struct with 5 fields + --> $DIR/bad-backtrace-decl.rs:LL:CC + | +LL | ... miri_resolve_frame(*frame, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bad declaration of miri_resolve_frame - should return a struct with 5 fields + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/bad-backtrace-decl.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-flags.stderr b/tests/compile-fail/backtrace/bad-backtrace-flags.stderr new file mode 100644 index 0000000000..f6ffe3c93c --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-flags.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unknown `miri_get_backtrace` flags 2 + --> $DIR/bad-backtrace-flags.rs:LL:CC + | +LL | miri_get_backtrace(2, 0 as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown `miri_get_backtrace` flags 2 + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/bad-backtrace-flags.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-ptr.stderr b/tests/compile-fail/backtrace/bad-backtrace-ptr.stderr new file mode 100644 index 0000000000..ed726a5dcd --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: null pointer is not a valid pointer for this operation + --> $DIR/bad-backtrace-ptr.rs:LL:CC + | +LL | miri_resolve_frame(0 as *mut _, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ null pointer is not a valid pointer for this operation + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/bad-backtrace-ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-resolve-flags.stderr b/tests/compile-fail/backtrace/bad-backtrace-resolve-flags.stderr new file mode 100644 index 0000000000..49495651df --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-resolve-flags.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unknown `miri_resolve_frame` flags 2 + --> $DIR/bad-backtrace-resolve-flags.rs:LL:CC + | +LL | miri_resolve_frame(buf[0], 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown `miri_resolve_frame` flags 2 + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/bad-backtrace-resolve-flags.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-resolve-names-flags.stderr b/tests/compile-fail/backtrace/bad-backtrace-resolve-names-flags.stderr new file mode 100644 index 0000000000..d575caa4ff --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-resolve-names-flags.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unknown `miri_resolve_frame_names` flags 2 + --> $DIR/bad-backtrace-resolve-names-flags.rs:LL:CC + | +LL | ... miri_resolve_frame_names(buf[0], 2, 0 as *mut _, 0 as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown `miri_resolve_frame_names` flags 2 + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/bad-backtrace-resolve-names-flags.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-size-flags.stderr b/tests/compile-fail/backtrace/bad-backtrace-size-flags.stderr new file mode 100644 index 0000000000..09f22b74b9 --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-size-flags.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unknown `miri_backtrace_size` flags 2 + --> $DIR/bad-backtrace-size-flags.rs:LL:CC + | +LL | miri_backtrace_size(2); + | ^^^^^^^^^^^^^^^^^^^^^^ unknown `miri_backtrace_size` flags 2 + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/bad-backtrace-size-flags.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/backtrace/bad-backtrace-version.stderr b/tests/compile-fail/backtrace/bad-backtrace-version.stderr new file mode 100644 index 0000000000..4e72927327 --- /dev/null +++ b/tests/compile-fail/backtrace/bad-backtrace-version.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unknown `miri_resolve_frame` flags 1 + --> $DIR/bad-backtrace-version.rs:7:9 + | +LL | miri_resolve_frame(0 as *mut _, 1); //~ ERROR unsupported operation: unknown `miri_resolve_frame` flags 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown `miri_resolve_frame` flags 1 + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/bad-backtrace-version.rs:7:9 + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/box-cell-alias.stderr b/tests/compile-fail/box-cell-alias.stderr new file mode 100644 index 0000000000..a4eaec93a8 --- /dev/null +++ b/tests/compile-fail/box-cell-alias.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/box-cell-alias.rs:LL:CC + | +LL | unsafe { (*ptr).set(20); } + | ^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x1] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x1] + --> $DIR/box-cell-alias.rs:LL:CC + | +LL | let ptr: *const Cell = &*val; + | ^^^^^ +help: was later invalidated at offsets [0x0..0x1] + --> $DIR/box-cell-alias.rs:LL:CC + | +LL | let res = helper(val, ptr); + | ^^^ + = note: inside `helper` at $DIR/box-cell-alias.rs:LL:CC +note: inside `main` at $DIR/box-cell-alias.rs:LL:CC + --> $DIR/box-cell-alias.rs:LL:CC + | +LL | let res = helper(val, ptr); + | ^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/branchless-select-i128-pointer.stderr b/tests/compile-fail/branchless-select-i128-pointer.stderr new file mode 100644 index 0000000000..2e0f813983 --- /dev/null +++ b/tests/compile-fail/branchless-select-i128-pointer.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered (potentially part of) a pointer, but expected plain (non-pointer) bytes + --> $DIR/branchless-select-i128-pointer.rs:LL:CC + | +LL | !mask & transmute::<_, TwoPtrs>("false !") | mask & transmute::<_, TwoPtrs>("true !"), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered (potentially part of) a pointer, but expected plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/branchless-select-i128-pointer.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/breakpoint.stderr b/tests/compile-fail/breakpoint.stderr new file mode 100644 index 0000000000..7b9bbdb382 --- /dev/null +++ b/tests/compile-fail/breakpoint.stderr @@ -0,0 +1,12 @@ +error: abnormal termination: Trace/breakpoint trap + --> $DIR/breakpoint.rs:LL:CC + | +LL | core::intrinsics::breakpoint() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace/breakpoint trap + | + = note: inside `main` at $DIR/breakpoint.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/concurrency/libc_pthread_create_main_terminate.stderr b/tests/compile-fail/concurrency/libc_pthread_create_main_terminate.stderr new file mode 100644 index 0000000000..0f7fbefe0a --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_create_main_terminate.stderr @@ -0,0 +1,8 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: the main thread terminated without waiting for all remaining threads + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/libc_pthread_join_detached.stderr b/tests/compile-fail/concurrency/libc_pthread_join_detached.stderr new file mode 100644 index 0000000000..688f61a98b --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_join_detached.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: trying to join a detached or already joined thread + --> $DIR/libc_pthread_join_detached.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached or already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_join_detached.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/libc_pthread_join_joined.stderr b/tests/compile-fail/concurrency/libc_pthread_join_joined.stderr new file mode 100644 index 0000000000..518f72de5b --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_join_joined.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: trying to join a detached or already joined thread + --> $DIR/libc_pthread_join_joined.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached or already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_join_joined.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/libc_pthread_join_main.stderr b/tests/compile-fail/concurrency/libc_pthread_join_main.stderr new file mode 100644 index 0000000000..5d9ec148e0 --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_join_main.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: trying to join a detached or already joined thread + --> $DIR/libc_pthread_join_main.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached or already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_join_main.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/libc_pthread_join_multiple.stderr b/tests/compile-fail/concurrency/libc_pthread_join_multiple.stderr new file mode 100644 index 0000000000..57126a14ae --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_join_multiple.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: trying to join a detached or already joined thread + --> $DIR/libc_pthread_join_multiple.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached or already joined thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_join_multiple.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/libc_pthread_join_self.stderr b/tests/compile-fail/concurrency/libc_pthread_join_self.stderr new file mode 100644 index 0000000000..d638d08939 --- /dev/null +++ b/tests/compile-fail/concurrency/libc_pthread_join_self.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: trying to join itself + --> $DIR/libc_pthread_join_self.rs:LL:CC + | +LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join itself + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_join_self.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/thread-spawn.rs b/tests/compile-fail/concurrency/thread-spawn.rs index 6f07d083a0..948ce946d8 100644 --- a/tests/compile-fail/concurrency/thread-spawn.rs +++ b/tests/compile-fail/concurrency/thread-spawn.rs @@ -1,5 +1,4 @@ -// ignore-linux: Only Windows is not supported. -// ignore-macos: Only Windows is not supported. +// only-windows: Only Windows is not supported. use std::thread; diff --git a/tests/compile-fail/concurrency/thread_local_static_dealloc.stderr b/tests/compile-fail/concurrency/thread_local_static_dealloc.stderr new file mode 100644 index 0000000000..cdeb22fb31 --- /dev/null +++ b/tests/compile-fail/concurrency/thread_local_static_dealloc.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/thread_local_static_dealloc.rs:LL:CC + | +LL | let _val = *(dangling_ptr as *const u8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/thread_local_static_dealloc.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/too_few_args.stderr b/tests/compile-fail/concurrency/too_few_args.stderr new file mode 100644 index 0000000000..753b5e9ea7 --- /dev/null +++ b/tests/compile-fail/concurrency/too_few_args.stderr @@ -0,0 +1,16 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: callee has fewer arguments than expected + --> $DIR/too_few_args.rs:LL:CC + | +LL | panic!() + | ^^^^^^^^ callee has fewer arguments than expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `thread_start` at rustc_src/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/too_many_args.stderr b/tests/compile-fail/concurrency/too_many_args.stderr new file mode 100644 index 0000000000..483b032a9b --- /dev/null +++ b/tests/compile-fail/concurrency/too_many_args.stderr @@ -0,0 +1,16 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: callee has more arguments than expected + --> $DIR/too_many_args.rs:LL:CC + | +LL | panic!() + | ^^^^^^^^ callee has more arguments than expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `thread_start` at rustc_src/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/concurrency/unwind_top_of_stack.stderr b/tests/compile-fail/concurrency/unwind_top_of_stack.stderr new file mode 100644 index 0000000000..600b8443d2 --- /dev/null +++ b/tests/compile-fail/concurrency/unwind_top_of_stack.stderr @@ -0,0 +1,19 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +thread '' panicked at 'explicit panic', $DIR/unwind_top_of_stack.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: Undefined Behavior: unwinding past the topmost frame of the stack + --> $DIR/unwind_top_of_stack.rs:LL:CC + | +LL | / extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { +LL | | panic!() +LL | | } + | |_^ unwinding past the topmost frame of the stack + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.stderr b/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.stderr new file mode 100644 index 0000000000..6638be3758 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/dangling_pointer_addr_of.rs:LL:CC + | +LL | let x = unsafe { ptr::addr_of!(*p) }; + | ^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at rustc_src/src/ptr/mod.rs:LL:CC + = note: this error originates in the macro `ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/dangling_pointer_deref.stderr b/tests/compile-fail/dangling_pointers/dangling_pointer_deref.stderr new file mode 100644 index 0000000000..69e7af7485 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/dangling_pointer_deref.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/dangling_pointer_deref.rs:LL:CC + | +LL | let x = unsafe { *p }; + | ^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_pointer_deref.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/dangling_zst_deref.stderr b/tests/compile-fail/dangling_pointers/dangling_zst_deref.stderr new file mode 100644 index 0000000000..658635433c --- /dev/null +++ b/tests/compile-fail/dangling_pointers/dangling_zst_deref.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/dangling_zst_deref.rs:LL:CC + | +LL | let _x = unsafe { *p }; + | ^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_zst_deref.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs b/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs index 87071d8b45..56830e97ca 100644 --- a/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs +++ b/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs @@ -3,5 +3,5 @@ fn main() { let x = 16usize as *const u32; - let _y = unsafe { &*x as *const u32 }; //~ ERROR 0x10 is not a valid pointer + let _y = unsafe { &*x as *const u32 }; //~ ERROR is not a valid pointer } diff --git a/tests/compile-fail/dangling_pointers/deref-invalid-ptr.stderr b/tests/compile-fail/dangling_pointers/deref-invalid-ptr.stderr new file mode 100644 index 0000000000..f4361d9fef --- /dev/null +++ b/tests/compile-fail/dangling_pointers/deref-invalid-ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: 0x10 is not a valid pointer + --> $DIR/deref-invalid-ptr.rs:LL:CC + | +LL | let _y = unsafe { &*x as *const u32 }; + | ^^^ dereferencing pointer failed: 0x10 is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/deref-invalid-ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/deref-partially-dangling.stderr b/tests/compile-fail/dangling_pointers/deref-partially-dangling.stderr new file mode 100644 index 0000000000..dc51eae71a --- /dev/null +++ b/tests/compile-fail/dangling_pointers/deref-partially-dangling.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 8, so pointer to 12 bytes starting at offset 0 is out-of-bounds + --> $DIR/deref-partially-dangling.rs:LL:CC + | +LL | let val = unsafe { (*xptr).1 }; + | ^^^^^^^^^ dereferencing pointer failed: ALLOC has size 8, so pointer to 12 bytes starting at offset 0 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/deref-partially-dangling.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/dyn_size.stderr b/tests/compile-fail/dangling_pointers/dyn_size.stderr new file mode 100644 index 0000000000..6048a3b443 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/dyn_size.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds + --> $DIR/dyn_size.rs:LL:CC + | +LL | let _ptr = unsafe { &*ptr }; + | ^^^^^ dereferencing pointer failed: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dyn_size.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.stderr b/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.stderr new file mode 100644 index 0000000000..b4da315a55 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds + --> $DIR/maybe_null_pointer_deref_zst.rs:LL:CC + | +LL | let _x: () = unsafe { *ptr }; + | ^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/maybe_null_pointer_deref_zst.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.stderr b/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.stderr new file mode 100644 index 0000000000..dc810424ab --- /dev/null +++ b/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds + --> $DIR/maybe_null_pointer_write_zst.rs:LL:CC + | +LL | unsafe { *ptr = zst_val; } + | ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/maybe_null_pointer_write_zst.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/null_pointer_deref.stderr b/tests/compile-fail/dangling_pointers/null_pointer_deref.stderr new file mode 100644 index 0000000000..0930160023 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/null_pointer_deref.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_deref.rs:LL:CC + | +LL | let x: i32 = unsafe { *std::ptr::null() }; + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_deref.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/null_pointer_deref_zst.stderr b/tests/compile-fail/dangling_pointers/null_pointer_deref_zst.stderr new file mode 100644 index 0000000000..25fea50b15 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/null_pointer_deref_zst.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_deref_zst.rs:LL:CC + | +LL | let x: () = unsafe { *std::ptr::null() }; + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_deref_zst.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/null_pointer_write.stderr b/tests/compile-fail/dangling_pointers/null_pointer_write.stderr new file mode 100644 index 0000000000..5ac8cc7c20 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/null_pointer_write.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_write.rs:LL:CC + | +LL | unsafe { *std::ptr::null_mut() = 0i32 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_write.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/null_pointer_write_zst.stderr b/tests/compile-fail/dangling_pointers/null_pointer_write_zst.stderr new file mode 100644 index 0000000000..b40a9154f1 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/null_pointer_write_zst.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: memory access failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::write::<[u8; 0]>` at rustc_src/src/ptr/mod.rs:LL:CC + = note: inside `std::ptr::mut_ptr::::write` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC + --> $DIR/null_pointer_write_zst.rs:LL:CC + | +LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/out_of_bounds_read1.stderr b/tests/compile-fail/dangling_pointers/out_of_bounds_read1.stderr new file mode 100644 index 0000000000..1982b07066 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/out_of_bounds_read1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 2, so pointer to 1 byte starting at offset 5 is out-of-bounds + --> $DIR/out_of_bounds_read1.rs:LL:CC + | +LL | let x = unsafe { *v.as_ptr().wrapping_offset(5) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 2, so pointer to 1 byte starting at offset 5 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/out_of_bounds_read1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/out_of_bounds_read2.stderr b/tests/compile-fail/dangling_pointers/out_of_bounds_read2.stderr new file mode 100644 index 0000000000..b70ce44c48 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/out_of_bounds_read2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 2, so pointer to 1 byte starting at offset 5 is out-of-bounds + --> $DIR/out_of_bounds_read2.rs:LL:CC + | +LL | let x = unsafe { *v.as_ptr().wrapping_offset(5) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 2, so pointer to 1 byte starting at offset 5 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/out_of_bounds_read2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/stack_temporary.stderr b/tests/compile-fail/dangling_pointers/stack_temporary.stderr new file mode 100644 index 0000000000..f4f84765be --- /dev/null +++ b/tests/compile-fail/dangling_pointers/stack_temporary.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/stack_temporary.rs:LL:CC + | +LL | let val = *x; + | ^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/stack_temporary.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/storage_dead_dangling.stderr b/tests/compile-fail/dangling_pointers/storage_dead_dangling.stderr new file mode 100644 index 0000000000..aed14105ad --- /dev/null +++ b/tests/compile-fail/dangling_pointers/storage_dead_dangling.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/storage_dead_dangling.rs:LL:CC + | +LL | unsafe { &mut *(LEAK as *mut i32) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `evil` at $DIR/storage_dead_dangling.rs:LL:CC +note: inside `main` at $DIR/storage_dead_dangling.rs:LL:CC + --> $DIR/storage_dead_dangling.rs:LL:CC + | +LL | evil(); + | ^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs b/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs index 2749ccfc0a..eebaea48ba 100644 --- a/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs +++ b/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs @@ -1,5 +1,5 @@ fn main() { let p = 44 as *const i32; - let x = unsafe { *p }; //~ ERROR 0x2c is not a valid pointer + let x = unsafe { *p }; //~ ERROR is not a valid pointer panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/dangling_pointers/wild_pointer_deref.stderr b/tests/compile-fail/dangling_pointers/wild_pointer_deref.stderr new file mode 100644 index 0000000000..b20f310da0 --- /dev/null +++ b/tests/compile-fail/dangling_pointers/wild_pointer_deref.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: 0x2c is not a valid pointer + --> $DIR/wild_pointer_deref.rs:LL:CC + | +LL | let x = unsafe { *p }; + | ^^ dereferencing pointer failed: 0x2c is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/wild_pointer_deref.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/data_race/alloc_read_race.stderr b/tests/compile-fail/data_race/alloc_read_race.stderr new file mode 100644 index 0000000000..9d9006966b --- /dev/null +++ b/tests/compile-fail/data_race/alloc_read_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 2) and Allocate on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/alloc_read_race.rs:LL:CC + | +LL | *pointer.load(Ordering::Relaxed) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Read on Thread(id = 2) and Allocate on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/alloc_read_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/alloc_write_race.stderr b/tests/compile-fail/data_race/alloc_write_race.stderr new file mode 100644 index 0000000000..318895cae6 --- /dev/null +++ b/tests/compile-fail/data_race/alloc_write_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 2) and Allocate on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/alloc_write_race.rs:LL:CC + | +LL | *pointer.load(Ordering::Relaxed) = 2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Write on Thread(id = 2) and Allocate on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/alloc_write_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_read_na_write_race1.stderr b/tests/compile-fail/data_race/atomic_read_na_write_race1.stderr new file mode 100644 index 0000000000..09d7accb05 --- /dev/null +++ b/tests/compile-fail/data_race/atomic_read_na_write_race1.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_read_na_write_race1.rs:LL:CC + | +LL | atomic_load(c.0 as *mut usize) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_read_na_write_race1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_read_na_write_race2.stderr b/tests/compile-fail/data_race/atomic_read_na_write_race2.stderr new file mode 100644 index 0000000000..739ce83d0b --- /dev/null +++ b/tests/compile-fail/data_race/atomic_read_na_write_race2.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 2) and Atomic Load on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_read_na_write_race2.rs:LL:CC + | +LL | *atomic_ref.get_mut() = 32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Write on Thread(id = 2) and Atomic Load on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_read_na_write_race2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_write_na_read_race1.stderr b/tests/compile-fail/data_race/atomic_write_na_read_race1.stderr new file mode 100644 index 0000000000..6d67f58aae --- /dev/null +++ b/tests/compile-fail/data_race/atomic_write_na_read_race1.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 2) and Atomic Store on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_write_na_read_race1.rs:LL:CC + | +LL | *atomic_ref.get_mut() + | ^^^^^^^^^^^^^^^^^^^^^ Data race detected between Read on Thread(id = 2) and Atomic Store on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_write_na_read_race1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_write_na_read_race2.stderr b/tests/compile-fail/data_race/atomic_write_na_read_race2.stderr new file mode 100644 index 0000000000..d9950ebcb7 --- /dev/null +++ b/tests/compile-fail/data_race/atomic_write_na_read_race2.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Atomic Store on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_write_na_read_race2.rs:LL:CC + | +LL | atomic_store(c.0 as *mut usize, 32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_write_na_read_race2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_write_na_write_race1.stderr b/tests/compile-fail/data_race/atomic_write_na_write_race1.stderr new file mode 100644 index 0000000000..29ccf70212 --- /dev/null +++ b/tests/compile-fail/data_race/atomic_write_na_write_race1.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Atomic Store on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_write_na_write_race1.rs:LL:CC + | +LL | atomic_store(c.0 as *mut usize, 64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_write_na_write_race1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/atomic_write_na_write_race2.stderr b/tests/compile-fail/data_race/atomic_write_na_write_race2.stderr new file mode 100644 index 0000000000..5488f05de0 --- /dev/null +++ b/tests/compile-fail/data_race/atomic_write_na_write_race2.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 2) and Atomic Store on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/atomic_write_na_write_race2.rs:LL:CC + | +LL | *atomic_ref.get_mut() = 32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Write on Thread(id = 2) and Atomic Store on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/atomic_write_na_write_race2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dangling_thread_async_race.stderr b/tests/compile-fail/data_race/dangling_thread_async_race.stderr new file mode 100644 index 0000000000..eccc243d69 --- /dev/null +++ b/tests/compile-fail/data_race/dangling_thread_async_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dangling_thread_async_race.rs:LL:CC + | +LL | *c.0 = 64; + | ^^^^^^^^^ Data race detected between Write on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dangling_thread_async_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dangling_thread_race.stderr b/tests/compile-fail/data_race/dangling_thread_race.stderr new file mode 100644 index 0000000000..4dffeb1423 --- /dev/null +++ b/tests/compile-fail/data_race/dangling_thread_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 0, name = "main") and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dangling_thread_race.rs:LL:CC + | +LL | *c.0 = 64; + | ^^^^^^^^^ Data race detected between Write on Thread(id = 0, name = "main") and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_thread_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_read_race1.stderr b/tests/compile-fail/data_race/dealloc_read_race1.stderr new file mode 100644 index 0000000000..37196021ea --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_read_race1.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dealloc_read_race1.rs:LL:CC + | +LL | __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::(), std::mem::align_of::()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_read_race1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_read_race2.stderr b/tests/compile-fail/data_race/dealloc_read_race2.stderr new file mode 100644 index 0000000000..03fb5dbea9 --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_read_race2.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/dealloc_read_race2.rs:LL:CC + | +LL | *ptr.0 + | ^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_read_race2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_read_race_stack.stderr b/tests/compile-fail/data_race/dealloc_read_race_stack.stderr new file mode 100644 index 0000000000..055724fe29 --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_read_race_stack.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 1) and Read on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dealloc_read_race_stack.rs:LL:CC + | +LL | } + | ^ Data race detected between Deallocate on Thread(id = 1) and Read on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_read_race_stack.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_write_race1.stderr b/tests/compile-fail/data_race/dealloc_write_race1.stderr new file mode 100644 index 0000000000..7160f49af6 --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_write_race1.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dealloc_write_race1.rs:LL:CC + | +LL | __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::(), std::mem::align_of::()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_write_race1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_write_race2.stderr b/tests/compile-fail/data_race/dealloc_write_race2.stderr new file mode 100644 index 0000000000..cb0d0af867 --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_write_race2.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/dealloc_write_race2.rs:LL:CC + | +LL | *ptr.0 = 2; + | ^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_write_race2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/dealloc_write_race_stack.stderr b/tests/compile-fail/data_race/dealloc_write_race_stack.stderr new file mode 100644 index 0000000000..05a8e1a8b7 --- /dev/null +++ b/tests/compile-fail/data_race/dealloc_write_race_stack.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/dealloc_write_race_stack.rs:LL:CC + | +LL | } + | ^ Data race detected between Deallocate on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/dealloc_write_race_stack.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/enable_after_join_to_main.stderr b/tests/compile-fail/data_race/enable_after_join_to_main.stderr new file mode 100644 index 0000000000..e612e08ade --- /dev/null +++ b/tests/compile-fail/data_race/enable_after_join_to_main.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 6) and Write on Thread(id = 5) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/enable_after_join_to_main.rs:LL:CC + | +LL | *c.0 = 64; + | ^^^^^^^^^ Data race detected between Write on Thread(id = 6) and Write on Thread(id = 5) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/enable_after_join_to_main.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/read_write_race.stderr b/tests/compile-fail/data_race/read_write_race.stderr new file mode 100644 index 0000000000..fc04141830 --- /dev/null +++ b/tests/compile-fail/data_race/read_write_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/read_write_race.rs:LL:CC + | +LL | *c.0 = 64; + | ^^^^^^^^^ Data race detected between Write on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/read_write_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/read_write_race_stack.stderr b/tests/compile-fail/data_race/read_write_race_stack.stderr new file mode 100644 index 0000000000..aad63731ca --- /dev/null +++ b/tests/compile-fail/data_race/read_write_race_stack.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/read_write_race_stack.rs:LL:CC + | +LL | stack_var + | ^^^^^^^^^ Data race detected between Read on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/read_write_race_stack.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/relax_acquire_race.stderr b/tests/compile-fail/data_race/relax_acquire_race.stderr new file mode 100644 index 0000000000..a437120c89 --- /dev/null +++ b/tests/compile-fail/data_race/relax_acquire_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/relax_acquire_race.rs:LL:CC + | +LL | *c.0 + | ^^^^ Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/relax_acquire_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/release_seq_race.stderr b/tests/compile-fail/data_race/release_seq_race.stderr new file mode 100644 index 0000000000..1a1c7ac64f --- /dev/null +++ b/tests/compile-fail/data_race/release_seq_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/release_seq_race.rs:LL:CC + | +LL | *c.0 + | ^^^^ Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/release_seq_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/release_seq_race_same_thread.stderr b/tests/compile-fail/data_race/release_seq_race_same_thread.stderr new file mode 100644 index 0000000000..f357c0647d --- /dev/null +++ b/tests/compile-fail/data_race/release_seq_race_same_thread.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/release_seq_race_same_thread.rs:LL:CC + | +LL | *c.0 + | ^^^^ Data race detected between Read on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/release_seq_race_same_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/rmw_race.stderr b/tests/compile-fail/data_race/rmw_race.stderr new file mode 100644 index 0000000000..dd3692c6dc --- /dev/null +++ b/tests/compile-fail/data_race/rmw_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/rmw_race.rs:LL:CC + | +LL | *c.0 + | ^^^^ Data race detected between Read on Thread(id = 3) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/rmw_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/write_write_race.stderr b/tests/compile-fail/data_race/write_write_race.stderr new file mode 100644 index 0000000000..dafee7dbf8 --- /dev/null +++ b/tests/compile-fail/data_race/write_write_race.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/write_write_race.rs:LL:CC + | +LL | *c.0 = 64; + | ^^^^^^^^^ Data race detected between Write on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/write_write_race.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/data_race/write_write_race_stack.stderr b/tests/compile-fail/data_race/write_write_race_stack.stderr new file mode 100644 index 0000000000..8d113673ac --- /dev/null +++ b/tests/compile-fail/data_race/write_write_race_stack.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: Data race detected between Write on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + --> $DIR/write_write_race_stack.rs:LL:CC + | +LL | stack_var = 1usize; + | ^^^^^^^^^^^^^^^^^^ Data race detected between Write on Thread(id = 1) and Write on Thread(id = 2) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/write_write_race_stack.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/environ-gets-deallocated.stderr b/tests/compile-fail/environ-gets-deallocated.stderr new file mode 100644 index 0000000000..640d953a81 --- /dev/null +++ b/tests/compile-fail/environ-gets-deallocated.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/environ-gets-deallocated.rs:LL:CC + | +LL | let _y = unsafe { *pointer }; + | ^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/environ-gets-deallocated.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/erroneous_const.stderr b/tests/compile-fail/erroneous_const.stderr new file mode 100644 index 0000000000..e1758ad657 --- /dev/null +++ b/tests/compile-fail/erroneous_const.stderr @@ -0,0 +1,26 @@ +error[E0080]: evaluation of `PrintName::::VOID` failed + --> $DIR/erroneous_const.rs:LL:CC + | +LL | const VOID: ! = panic!(); + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/erroneous_const.rs:LL:CC + | + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: post-monomorphization error: encountered constants with type errors, stopping evaluation + --> $DIR/erroneous_const.rs:LL:CC + | +LL | let _ = PrintName::::VOID; + | ^^^^^^^^^^^^^^^^^^^^ encountered constants with type errors, stopping evaluation + | + = note: inside `no_codegen::` at $DIR/erroneous_const.rs:LL:CC +note: inside `main` at $DIR/erroneous_const.rs:LL:CC + --> $DIR/erroneous_const.rs:LL:CC + | +LL | no_codegen::(); + | ^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/compile-fail/erroneous_const2.stderr b/tests/compile-fail/erroneous_const2.stderr new file mode 100644 index 0000000000..d5c89a8e82 --- /dev/null +++ b/tests/compile-fail/erroneous_const2.stderr @@ -0,0 +1,41 @@ +error: any use of this value will cause an error + --> $DIR/erroneous_const2.rs:LL:CC + | +LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; + | ------------------^^^^^--------------------------- + | | + | attempt to compute `5_u32 - 6_u32`, which would overflow + | + = note: `#[deny(const_err)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + +error[E0080]: evaluation of constant value failed + --> $DIR/erroneous_const2.rs:LL:CC + | +LL | println!("{}", FOO); + | ^^^ referenced constant has errors + +error: erroneous constant used + --> $DIR/erroneous_const2.rs:LL:CC + | +LL | println!("{}", FOO); + | ^^^ referenced constant has errors + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: post-monomorphization error: referenced constant has errors + --> $DIR/erroneous_const2.rs:LL:CC + | +LL | println!("{}", FOO); + | ^^^ referenced constant has errors + | + = note: inside `main` at $DIR/erroneous_const2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/compile-fail/extern_static.stderr b/tests/compile-fail/extern_static.stderr new file mode 100644 index 0000000000..e673d074bc --- /dev/null +++ b/tests/compile-fail/extern_static.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: `extern` static `FOO` from crate `extern_static` is not supported by Miri + --> $DIR/extern_static.rs:LL:CC + | +LL | let _val = unsafe { std::ptr::addr_of!(FOO) }; + | ^^^ `extern` static `FOO` from crate `extern_static` is not supported by Miri + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/extern_static.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fast_math_both.stderr b/tests/compile-fail/fast_math_both.stderr new file mode 100644 index 0000000000..542044df4d --- /dev/null +++ b/tests/compile-fail/fast_math_both.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `fsub_fast` intrinsic called with non-finite value as both parameters + --> $DIR/fast_math_both.rs:LL:CC + | +LL | ...: f32 = core::intrinsics::fsub_fast(f32::NAN, f32::NAN); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fsub_fast` intrinsic called with non-finite value as both parameters + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/fast_math_both.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fast_math_first.stderr b/tests/compile-fail/fast_math_first.stderr new file mode 100644 index 0000000000..74ba08dc87 --- /dev/null +++ b/tests/compile-fail/fast_math_first.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `frem_fast` intrinsic called with non-finite value as first parameter + --> $DIR/fast_math_first.rs:LL:CC + | +LL | ... let _x: f32 = core::intrinsics::frem_fast(f32::NAN, 3.2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `frem_fast` intrinsic called with non-finite value as first parameter + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/fast_math_first.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fast_math_second.stderr b/tests/compile-fail/fast_math_second.stderr new file mode 100644 index 0000000000..cbb059a07f --- /dev/null +++ b/tests/compile-fail/fast_math_second.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `fmul_fast` intrinsic called with non-finite value as second parameter + --> $DIR/fast_math_second.rs:LL:CC + | +LL | ...f32 = core::intrinsics::fmul_fast(3.4f32, f32::INFINITY); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `fmul_fast` intrinsic called with non-finite value as second parameter + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/fast_math_second.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/close_stdout.stderr b/tests/compile-fail/fs/close_stdout.stderr new file mode 100644 index 0000000000..79fa0458b4 --- /dev/null +++ b/tests/compile-fail/fs/close_stdout.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: stdout cannot be closed + --> $DIR/close_stdout.rs:LL:CC + | +LL | libc::close(1); + | ^^^^^^^^^^^^^^ stdout cannot be closed + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/close_stdout.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/isolated_file.stderr b/tests/compile-fail/fs/isolated_file.stderr new file mode 100644 index 0000000000..056a67259c --- /dev/null +++ b/tests/compile-fail/fs/isolated_file.stderr @@ -0,0 +1,22 @@ +error: unsupported operation: `open` not available when isolation is enabled + | + = help: pass the flag `-Zmiri-disable-isolation` to disable isolation; + = help: or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning + + = note: inside closure at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC + = note: inside `std::sys::PLATFORM::cvt_r::` at rustc_src/src/sys/PLATFORM/mod.rs:LL:CC + = note: inside `std::sys::PLATFORM::fs::File::open_c` at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC + = note: inside `std::sys::PLATFORM::fs::File::open` at rustc_src/src/sys/PLATFORM/fs.rs:LL:CC + = note: inside `std::fs::OpenOptions::_open` at rustc_src/src/fs.rs:LL:CC + = note: inside `std::fs::OpenOptions::open::<&std::path::Path>` at rustc_src/src/fs.rs:LL:CC + = note: inside `std::fs::File::open::<&str>` at rustc_src/src/fs.rs:LL:CC +note: inside `main` at $DIR/isolated_file.rs:LL:CC + --> $DIR/isolated_file.rs:LL:CC + | +LL | let _file = std::fs::File::open("file.txt").unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/isolated_stdin.stderr b/tests/compile-fail/fs/isolated_stdin.stderr new file mode 100644 index 0000000000..4fbd11e7cd --- /dev/null +++ b/tests/compile-fail/fs/isolated_stdin.stderr @@ -0,0 +1,15 @@ +error: unsupported operation: `read` from stdin not available when isolation is enabled + --> $DIR/isolated_stdin.rs:LL:CC + | +LL | libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `read` from stdin not available when isolation is enabled + | + = help: pass the flag `-Zmiri-disable-isolation` to disable isolation; + = help: or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning + + = note: inside `main` at $DIR/isolated_stdin.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/read_from_stdout.stderr b/tests/compile-fail/fs/read_from_stdout.stderr new file mode 100644 index 0000000000..45573c471e --- /dev/null +++ b/tests/compile-fail/fs/read_from_stdout.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot read from stdout + --> $DIR/read_from_stdout.rs:LL:CC + | +LL | libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot read from stdout + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/read_from_stdout.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/unix_open_missing_required_mode.stderr b/tests/compile-fail/fs/unix_open_missing_required_mode.stderr new file mode 100644 index 0000000000..7003234331 --- /dev/null +++ b/tests/compile-fail/fs/unix_open_missing_required_mode.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 + --> $DIR/unix_open_missing_required_mode.rs:LL:CC + | +LL | ...safe { libc::open(name_ptr, libc::O_CREAT) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `test_file_open_missing_needed_mode` at $DIR/unix_open_missing_required_mode.rs:LL:CC +note: inside `main` at $DIR/unix_open_missing_required_mode.rs:LL:CC + --> $DIR/unix_open_missing_required_mode.rs:LL:CC + | +LL | test_file_open_missing_needed_mode(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/unix_open_too_many_args.stderr b/tests/compile-fail/fs/unix_open_too_many_args.stderr new file mode 100644 index 0000000000..f71a44d34d --- /dev/null +++ b/tests/compile-fail/fs/unix_open_too_many_args.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: incorrect number of arguments for `open`: got 4, expected 2 or 3 + --> $DIR/unix_open_too_many_args.rs:15:24 + | +LL | let _fd = unsafe { libc::open(name_ptr, libc::O_RDONLY, 0, 0) }; //~ ERROR Undefined Behavior: incorrect number of arguments for `ope... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of arguments for `open`: got 4, expected 2 or 3 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `test_open_too_many_args` at $DIR/unix_open_too_many_args.rs:15:24 +note: inside `main` at $DIR/unix_open_too_many_args.rs:9:5 + --> $DIR/unix_open_too_many_args.rs:9:5 + | +LL | test_open_too_many_args(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/fs/write_to_stdin.stderr b/tests/compile-fail/fs/write_to_stdin.stderr new file mode 100644 index 0000000000..1cbc3eef66 --- /dev/null +++ b/tests/compile-fail/fs/write_to_stdin.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot write to stdin + --> $DIR/write_to_stdin.rs:LL:CC + | +LL | libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot write to stdin + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/write_to_stdin.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/check_arg_abi.stderr b/tests/compile-fail/function_calls/check_arg_abi.stderr new file mode 100644 index 0000000000..9ee7d301b1 --- /dev/null +++ b/tests/compile-fail/function_calls/check_arg_abi.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with ABI C using caller ABI Rust + --> $DIR/check_arg_abi.rs:LL:CC + | +LL | let _ = malloc(0); + | ^^^^^^^^^ calling a function with ABI C using caller ABI Rust + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/check_arg_abi.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/check_arg_count_abort.stderr b/tests/compile-fail/function_calls/check_arg_count_abort.stderr new file mode 100644 index 0000000000..c7682578f9 --- /dev/null +++ b/tests/compile-fail/function_calls/check_arg_count_abort.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: incorrect number of arguments: got 1, expected 0 + --> $DIR/check_arg_count_abort.rs:LL:CC + | +LL | abort(1); + | ^^^^^^^^ incorrect number of arguments: got 1, expected 0 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/check_arg_count_abort.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/check_arg_count_too_few_args.stderr b/tests/compile-fail/function_calls/check_arg_count_too_few_args.stderr new file mode 100644 index 0000000000..b7d6bbfd57 --- /dev/null +++ b/tests/compile-fail/function_calls/check_arg_count_too_few_args.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: incorrect number of arguments: got 0, expected 1 + --> $DIR/check_arg_count_too_few_args.rs:LL:CC + | +LL | let _ = malloc(); + | ^^^^^^^^ incorrect number of arguments: got 0, expected 1 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/check_arg_count_too_few_args.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/check_arg_count_too_many_args.stderr b/tests/compile-fail/function_calls/check_arg_count_too_many_args.stderr new file mode 100644 index 0000000000..33cc5750b8 --- /dev/null +++ b/tests/compile-fail/function_calls/check_arg_count_too_many_args.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: incorrect number of arguments: got 2, expected 1 + --> $DIR/check_arg_count_too_many_args.rs:LL:CC + | +LL | let _ = malloc(1, 2); + | ^^^^^^^^^^^^ incorrect number of arguments: got 2, expected 1 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/check_arg_count_too_many_args.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/check_callback_abi.stderr b/tests/compile-fail/function_calls/check_callback_abi.stderr new file mode 100644 index 0000000000..ea7c2bb6b4 --- /dev/null +++ b/tests/compile-fail/function_calls/check_callback_abi.stderr @@ -0,0 +1,19 @@ +error: Undefined Behavior: calling a function with ABI C using caller ABI Rust + --> $DIR/check_callback_abi.rs:LL:CC + | +LL | / std::intrinsics::r#try( +LL | | std::mem::transmute::(try_fn), +LL | | std::ptr::null_mut(), +LL | | |_, _| unreachable!(), +LL | | ); + | |_________^ calling a function with ABI C using caller ABI Rust + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/check_callback_abi.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.cache.stderr b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.cache.stderr new file mode 100644 index 0000000000..bf0d27d915 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.cache.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with calling convention Rust using calling convention C + --> $DIR/exported_symbol_abi_mismatch.rs:LL:CC + | +LL | unsafe { foo() } + | ^^^^^ calling a function with calling convention Rust using calling convention C + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_abi_mismatch.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.fn_ptr.stderr b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.fn_ptr.stderr new file mode 100644 index 0000000000..ee810af315 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.fn_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with calling convention Rust using calling convention C + --> $DIR/exported_symbol_abi_mismatch.rs:LL:CC + | +LL | unsafe { std::mem::transmute::(foo)() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention Rust using calling convention C + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_abi_mismatch.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.no_cache.stderr b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.no_cache.stderr new file mode 100644 index 0000000000..bf0d27d915 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_abi_mismatch.no_cache.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with calling convention Rust using calling convention C + --> $DIR/exported_symbol_abi_mismatch.rs:LL:CC + | +LL | unsafe { foo() } + | ^^^^^ calling a function with calling convention Rust using calling convention C + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_abi_mismatch.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_bad_unwind1.stderr b/tests/compile-fail/function_calls/exported_symbol_bad_unwind1.stderr new file mode 100644 index 0000000000..8cd74f1fd8 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_bad_unwind1.stderr @@ -0,0 +1,17 @@ +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind1.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding + --> $DIR/exported_symbol_bad_unwind1.rs:LL:CC + | +LL | unsafe { unwind() } + | ^^^^^^^^ unwinding past a stack frame that does not allow unwinding + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_bad_unwind1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.both.stderr b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.both.stderr new file mode 100644 index 0000000000..48df075ba6 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.both.stderr @@ -0,0 +1,23 @@ +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC + | +LL | / extern "C-unwind" fn nounwind() { +LL | | //[definition]~^ ERROR abnormal termination: the program aborted execution +LL | | //[both]~^^ ERROR abnormal termination: the program aborted execution +LL | | panic!(); +LL | | } + | |_^ the program aborted execution + | + = note: inside `nounwind` at $DIR/exported_symbol_bad_unwind2.rs:LL:CC +note: inside `main` at $DIR/exported_symbol_bad_unwind2.rs:LL:CC + --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC + | +LL | unsafe { nounwind() } + | ^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.definition.stderr b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.definition.stderr new file mode 100644 index 0000000000..48df075ba6 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.definition.stderr @@ -0,0 +1,23 @@ +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC + | +LL | / extern "C-unwind" fn nounwind() { +LL | | //[definition]~^ ERROR abnormal termination: the program aborted execution +LL | | //[both]~^^ ERROR abnormal termination: the program aborted execution +LL | | panic!(); +LL | | } + | |_^ the program aborted execution + | + = note: inside `nounwind` at $DIR/exported_symbol_bad_unwind2.rs:LL:CC +note: inside `main` at $DIR/exported_symbol_bad_unwind2.rs:LL:CC + --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC + | +LL | unsafe { nounwind() } + | ^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr new file mode 100644 index 0000000000..fac42bf66a --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr @@ -0,0 +1,17 @@ +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_bad_unwind2.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding + --> $DIR/exported_symbol_bad_unwind2.rs:LL:CC + | +LL | unsafe { nounwind() } + | ^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_bad_unwind2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_clashing.stderr b/tests/compile-fail/function_calls/exported_symbol_clashing.stderr new file mode 100644 index 0000000000..1ddd882c4c --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_clashing.stderr @@ -0,0 +1,22 @@ +error: multiple definitions of symbol `foo` + --> $DIR/exported_symbol_clashing.rs:LL:CC + | +LL | unsafe { foo() } + | ^^^^^ multiple definitions of symbol `foo` + | +help: it's first defined here, in crate `exported_symbol_clashing` + --> $DIR/exported_symbol_clashing.rs:LL:CC + | +LL | fn foo() {} + | ^^^^^^^^ +help: then it's defined here again, in crate `exported_symbol_clashing` + --> $DIR/exported_symbol_clashing.rs:LL:CC + | +LL | fn bar() {} + | ^^^^^^^^ + = note: inside `main` at $DIR/exported_symbol_clashing.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_shim_clashing.stderr b/tests/compile-fail/function_calls/exported_symbol_shim_clashing.stderr new file mode 100644 index 0000000000..fa25b4e3f3 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_shim_clashing.stderr @@ -0,0 +1,20 @@ +error: found `malloc` symbol definition that clashes with a built-in shim + --> $DIR/exported_symbol_shim_clashing.rs:LL:CC + | +LL | malloc(0); + | ^^^^^^^^^ found `malloc` symbol definition that clashes with a built-in shim + | +help: the `malloc` symbol is defined here + --> $DIR/exported_symbol_shim_clashing.rs:LL:CC + | +LL | / extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void { +LL | | +LL | | unreachable!() +LL | | } + | |_^ + = note: inside `main` at $DIR/exported_symbol_shim_clashing.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_wrong_arguments.stderr b/tests/compile-fail/function_calls/exported_symbol_wrong_arguments.stderr new file mode 100644 index 0000000000..fe5498c85d --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_wrong_arguments.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with more arguments than it expected + --> $DIR/exported_symbol_wrong_arguments.rs:LL:CC + | +LL | unsafe { foo(1) } + | ^^^^^^ calling a function with more arguments than it expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_wrong_arguments.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_calls/exported_symbol_wrong_type.stderr b/tests/compile-fail/function_calls/exported_symbol_wrong_type.stderr new file mode 100644 index 0000000000..f402704908 --- /dev/null +++ b/tests/compile-fail/function_calls/exported_symbol_wrong_type.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: attempt to call an exported symbol that is not defined as a function + --> $DIR/exported_symbol_wrong_type.rs:LL:CC + | +LL | unsafe { FOO() } + | ^^^^^ attempt to call an exported symbol that is not defined as a function + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exported_symbol_wrong_type.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.stderr b/tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.stderr new file mode 100644 index 0000000000..13f8ef3782 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using ALLOC as function pointer but it does not point to a function + --> $DIR/cast_box_int_to_fn_ptr.rs:LL:CC + | +LL | (*g)(42) + | ^^^^^^^^ using ALLOC as function pointer but it does not point to a function + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_box_int_to_fn_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr1.stderr b/tests/compile-fail/function_pointers/cast_fn_ptr1.stderr new file mode 100644 index 0000000000..765dbb6578 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_fn_ptr1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with more arguments than it expected + --> $DIR/cast_fn_ptr1.rs:LL:CC + | +LL | g(42) + | ^^^^^ calling a function with more arguments than it expected + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr2.stderr b/tests/compile-fail/function_pointers/cast_fn_ptr2.stderr new file mode 100644 index 0000000000..123d0e1b0b --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_fn_ptr2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with argument of type (i32, i32) passing data of type i32 + --> $DIR/cast_fn_ptr2.rs:LL:CC + | +LL | g(42) + | ^^^^^ calling a function with argument of type (i32, i32) passing data of type i32 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr3.stderr b/tests/compile-fail/function_pointers/cast_fn_ptr3.stderr new file mode 100644 index 0000000000..51f6ca0713 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_fn_ptr3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with fewer arguments than it requires + --> $DIR/cast_fn_ptr3.rs:LL:CC + | +LL | g() + | ^^^ calling a function with fewer arguments than it requires + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr4.stderr b/tests/compile-fail/function_pointers/cast_fn_ptr4.stderr new file mode 100644 index 0000000000..515f00ec39 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_fn_ptr4.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with argument of type *const [i32] passing data of type *const i32 + --> $DIR/cast_fn_ptr4.rs:LL:CC + | +LL | g(&42 as *const i32) + | ^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type *const [i32] passing data of type *const i32 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr5.stderr b/tests/compile-fail/function_pointers/cast_fn_ptr5.stderr new file mode 100644 index 0000000000..2978866c92 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_fn_ptr5.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with return type u32 passing return place of type () + --> $DIR/cast_fn_ptr5.rs:LL:CC + | +LL | g() + | ^^^ calling a function with return type u32 passing return place of type () + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr5.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs b/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs index 299fd5ae49..b206cb9ab3 100644 --- a/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs +++ b/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs @@ -6,5 +6,5 @@ fn main() { std::mem::transmute::(42) }; - g(42) //~ ERROR 0x2a is not a valid pointer + g(42) //~ ERROR not a valid pointer } diff --git a/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.stderr b/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.stderr new file mode 100644 index 0000000000..25501e7491 --- /dev/null +++ b/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: 0x2a is not a valid pointer + --> $DIR/cast_int_to_fn_ptr.rs:LL:CC + | +LL | g(42) + | ^^^^^ 0x2a is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_int_to_fn_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/deref_fn_ptr.stderr b/tests/compile-fail/function_pointers/deref_fn_ptr.stderr new file mode 100644 index 0000000000..1e3da2726d --- /dev/null +++ b/tests/compile-fail/function_pointers/deref_fn_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing ALLOC which contains a function + --> $DIR/deref_fn_ptr.rs:LL:CC + | +LL | *std::mem::transmute::(f) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing ALLOC which contains a function + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/deref_fn_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/execute_memory.stderr b/tests/compile-fail/function_pointers/execute_memory.stderr new file mode 100644 index 0000000000..daa6277b85 --- /dev/null +++ b/tests/compile-fail/function_pointers/execute_memory.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using ALLOC as function pointer but it does not point to a function + --> $DIR/execute_memory.rs:LL:CC + | +LL | f() + | ^^^ using ALLOC as function pointer but it does not point to a function + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/execute_memory.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/function_pointers/fn_ptr_offset.stderr b/tests/compile-fail/function_pointers/fn_ptr_offset.stderr new file mode 100644 index 0000000000..0f3baab1b5 --- /dev/null +++ b/tests/compile-fail/function_pointers/fn_ptr_offset.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using ALLOC+0x1 as function pointer but it does not point to a function + --> $DIR/fn_ptr_offset.rs:LL:CC + | +LL | x(); + | ^^^ using ALLOC+0x1 as function pointer but it does not point to a function + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/fn_ptr_offset.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/generator-pinned-moved.stderr b/tests/compile-fail/generator-pinned-moved.stderr new file mode 100644 index 0000000000..98ccf3097c --- /dev/null +++ b/tests/compile-fail/generator-pinned-moved.stderr @@ -0,0 +1,26 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/generator-pinned-moved.rs:LL:CC + | +LL | *num += 1; + | ^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/generator-pinned-moved.rs:LL:CC +note: inside ` as std::iter::Iterator>::next` at $DIR/generator-pinned-moved.rs:LL:CC + --> $DIR/generator-pinned-moved.rs:LL:CC + | +LL | match me.resume(()) { + | ^^^^^^^^^^^^^ + = note: inside `> as std::iter::Iterator>::next` at rustc_src/src/boxed.rs:LL:CC +note: inside `main` at $DIR/generator-pinned-moved.rs:LL:CC + --> $DIR/generator-pinned-moved.rs:LL:CC + | +LL | generator_iterator_2.next(); // and use moved value + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/assume.stderr b/tests/compile-fail/intrinsics/assume.stderr new file mode 100644 index 0000000000..e5059a699b --- /dev/null +++ b/tests/compile-fail/intrinsics/assume.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `assume` intrinsic called with `false` + --> $DIR/assume.rs:LL:CC + | +LL | std::intrinsics::assume(x > 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` intrinsic called with `false` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/assume.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/copy_null.stderr b/tests/compile-fail/intrinsics/copy_null.stderr new file mode 100644 index 0000000000..461f529fa8 --- /dev/null +++ b/tests/compile-fail/intrinsics/copy_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: memory access failed: null pointer is not a valid pointer + --> $DIR/copy_null.rs:LL:CC + | +LL | unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/copy_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/copy_overflow.stderr b/tests/compile-fail/intrinsics/copy_overflow.stderr new file mode 100644 index 0000000000..512184a36c --- /dev/null +++ b/tests/compile-fail/intrinsics/copy_overflow.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: overflow computing total size of `copy` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::intrinsics::copy::` at rustc_src/src/intrinsics.rs:LL:CC + = note: inside `std::ptr::mut_ptr::::copy_from` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/copy_overflow.rs:LL:CC + --> $DIR/copy_overflow.rs:LL:CC + | +LL | (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::() * 8 - 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/copy_overlapping.stderr b/tests/compile-fail/intrinsics/copy_overlapping.stderr new file mode 100644 index 0000000000..cba08d9b5c --- /dev/null +++ b/tests/compile-fail/intrinsics/copy_overlapping.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: copy_nonoverlapping called on overlapping ranges + --> $DIR/copy_overlapping.rs:LL:CC + | +LL | copy_nonoverlapping(a, b, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ copy_nonoverlapping called on overlapping ranges + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/copy_overlapping.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/copy_unaligned.rs b/tests/compile-fail/intrinsics/copy_unaligned.rs index 84f4de9346..7aff0adc40 100644 --- a/tests/compile-fail/intrinsics/copy_unaligned.rs +++ b/tests/compile-fail/intrinsics/copy_unaligned.rs @@ -9,5 +9,5 @@ fn main() { let mut data = [0u16; 8]; let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16; // Even copying 0 elements to something unaligned should error - unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment 1, but alignment 2 is required + unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment ALIGN, but alignment ALIGN is required } diff --git a/tests/compile-fail/intrinsics/copy_unaligned.stderr b/tests/compile-fail/intrinsics/copy_unaligned.stderr new file mode 100644 index 0000000000..b99588698d --- /dev/null +++ b/tests/compile-fail/intrinsics/copy_unaligned.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/copy_unaligned.rs:LL:CC + | +LL | unsafe { copy_nonoverlapping(&data[5], ptr, 0); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/copy_unaligned.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ctlz_nonzero.stderr b/tests/compile-fail/intrinsics/ctlz_nonzero.stderr new file mode 100644 index 0000000000..0c895cf138 --- /dev/null +++ b/tests/compile-fail/intrinsics/ctlz_nonzero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `ctlz_nonzero` called on 0 + --> $DIR/ctlz_nonzero.rs:LL:CC + | +LL | ctlz_nonzero(0u8); + | ^^^^^^^^^^^^^^^^^ `ctlz_nonzero` called on 0 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ctlz_nonzero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/cttz_nonzero.stderr b/tests/compile-fail/intrinsics/cttz_nonzero.stderr new file mode 100644 index 0000000000..5257668d53 --- /dev/null +++ b/tests/compile-fail/intrinsics/cttz_nonzero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `cttz_nonzero` called on 0 + --> $DIR/cttz_nonzero.rs:LL:CC + | +LL | cttz_nonzero(0u8); + | ^^^^^^^^^^^^^^^^^ `cttz_nonzero` called on 0 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cttz_nonzero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/div-by-zero.stderr b/tests/compile-fail/intrinsics/div-by-zero.stderr new file mode 100644 index 0000000000..388f4aef7f --- /dev/null +++ b/tests/compile-fail/intrinsics/div-by-zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dividing by zero + --> $DIR/div-by-zero.rs:LL:CC + | +LL | let _n = unchecked_div(1i64, 0); + | ^^^^^^^^^^^^^^^^^^^^^^ dividing by zero + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/div-by-zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/exact_div1.stderr b/tests/compile-fail/intrinsics/exact_div1.stderr new file mode 100644 index 0000000000..a0f03b201a --- /dev/null +++ b/tests/compile-fail/intrinsics/exact_div1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calculating the remainder with a divisor of zero + --> $DIR/exact_div1.rs:LL:CC + | +LL | unsafe { std::intrinsics::exact_div(2, 0); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exact_div1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/exact_div2.stderr b/tests/compile-fail/intrinsics/exact_div2.stderr new file mode 100644 index 0000000000..78a85c9caa --- /dev/null +++ b/tests/compile-fail/intrinsics/exact_div2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: exact_div: 2_u16 cannot be divided by 3_u16 without remainder + --> $DIR/exact_div2.rs:LL:CC + | +LL | unsafe { std::intrinsics::exact_div(2u16, 3); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exact_div2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/exact_div3.stderr b/tests/compile-fail/intrinsics/exact_div3.stderr new file mode 100644 index 0000000000..3062b60d46 --- /dev/null +++ b/tests/compile-fail/intrinsics/exact_div3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: exact_div: -19_i8 cannot be divided by 2_i8 without remainder + --> $DIR/exact_div3.rs:LL:CC + | +LL | unsafe { std::intrinsics::exact_div(-19i8, 2); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exact_div3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/exact_div4.stderr b/tests/compile-fail/intrinsics/exact_div4.stderr new file mode 100644 index 0000000000..1ae67ad87a --- /dev/null +++ b/tests/compile-fail/intrinsics/exact_div4.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow in signed remainder (dividing MIN by -1) + --> $DIR/exact_div4.rs:LL:CC + | +LL | unsafe { std::intrinsics::exact_div(i64::MIN, -1); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/exact_div4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_inf1.stderr b/tests/compile-fail/intrinsics/float_to_int_32_inf1.stderr new file mode 100644 index 0000000000..cdf232d93e --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_inf1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `i32` + --> $DIR/float_to_int_32_inf1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f32::INFINITY); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_inf1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_infneg1.stderr b/tests/compile-fail/intrinsics/float_to_int_32_infneg1.stderr new file mode 100644 index 0000000000..ae73011936 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_infneg1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i32` + --> $DIR/float_to_int_32_infneg1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f32::NEG_INFINITY); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_infneg1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_nan.stderr b/tests/compile-fail/intrinsics/float_to_int_32_nan.stderr new file mode 100644 index 0000000000..9c20abef78 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_nan.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + --> $DIR/float_to_int_32_nan.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f32::NAN); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_nan.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_nanneg.stderr b/tests/compile-fail/intrinsics/float_to_int_32_nanneg.stderr new file mode 100644 index 0000000000..f5675fd654 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_nanneg.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + --> $DIR/float_to_int_32_nanneg.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-f32::NAN); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_nanneg.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_neg.stderr b/tests/compile-fail/intrinsics/float_to_int_32_neg.stderr new file mode 100644 index 0000000000..3b7c755af6 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_neg.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u32` + --> $DIR/float_to_int_32_neg.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-1.000000001f32); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_neg.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_big1.stderr b/tests/compile-fail/intrinsics/float_to_int_32_too_big1.stderr new file mode 100644 index 0000000000..abfda9eef0 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_big1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 2.14748365E+9 which cannot be represented in target type `i32` + --> $DIR/float_to_int_32_too_big1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(2147483648.0f32); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 2.14748365E+9 which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_too_big1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_big2.stderr b/tests/compile-fail/intrinsics/float_to_int_32_too_big2.stderr new file mode 100644 index 0000000000..2680d0c990 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_big2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 4.2949673E+9 which cannot be represented in target type `u32` + --> $DIR/float_to_int_32_too_big2.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::((u32::MAX-127) as f32); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 4.2949673E+9 which cannot be represented in target type `u32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_too_big2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_32_too_small1.stderr b/tests/compile-fail/intrinsics/float_to_int_32_too_small1.stderr new file mode 100644 index 0000000000..b03bd380df --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_32_too_small1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -2.1474839E+9 which cannot be represented in target type `i32` + --> $DIR/float_to_int_32_too_small1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-2147483904.0f32); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -2.1474839E+9 which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_32_too_small1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_inf1.stderr b/tests/compile-fail/intrinsics/float_to_int_64_inf1.stderr new file mode 100644 index 0000000000..7509844cfd --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_inf1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `u128` + --> $DIR/float_to_int_64_inf1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::INFINITY); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `u128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_inf1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_infneg1.stderr b/tests/compile-fail/intrinsics/float_to_int_64_infneg1.stderr new file mode 100644 index 0000000000..539cd52d83 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_infneg1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `u128` + --> $DIR/float_to_int_64_infneg1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::NEG_INFINITY); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `u128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_infneg1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_infneg2.stderr b/tests/compile-fail/intrinsics/float_to_int_64_infneg2.stderr new file mode 100644 index 0000000000..ceb18c3f41 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_infneg2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i128` + --> $DIR/float_to_int_64_infneg2.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::NEG_INFINITY); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_infneg2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_nan.stderr b/tests/compile-fail/intrinsics/float_to_int_64_nan.stderr new file mode 100644 index 0000000000..eee8d2fac0 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_nan.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + --> $DIR/float_to_int_64_nan.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::NAN); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_nan.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_neg.stderr b/tests/compile-fail/intrinsics/float_to_int_64_neg.stderr new file mode 100644 index 0000000000..384c023246 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_neg.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u128` + --> $DIR/float_to_int_64_neg.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-1.0000000000001f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_neg.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big1.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big1.stderr new file mode 100644 index 0000000000..bb5b10a271 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 2147483648 which cannot be represented in target type `i32` + --> $DIR/float_to_int_64_too_big1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(2147483648.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 2147483648 which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big2.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big2.stderr new file mode 100644 index 0000000000..a4d57c2f5c --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 9.2233720368547758E+18 which cannot be represented in target type `i64` + --> $DIR/float_to_int_64_too_big2.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(9223372036854775808.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 9.2233720368547758E+18 which cannot be represented in target type `i64` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big3.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big3.stderr new file mode 100644 index 0000000000..2b7379fcbd --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 1.8446744073709552E+19 which cannot be represented in target type `u64` + --> $DIR/float_to_int_64_too_big3.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(18446744073709551616.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 1.8446744073709552E+19 which cannot be represented in target type `u64` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big4.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big4.stderr new file mode 100644 index 0000000000..d30817607b --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big4.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 3.4028236692093846E+38 which cannot be represented in target type `u128` + --> $DIR/float_to_int_64_too_big4.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(u128::MAX as f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 3.4028236692093846E+38 which cannot be represented in target type `u128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big5.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big5.stderr new file mode 100644 index 0000000000..f6b0c0a352 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big5.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 2.4028236692093845E+38 which cannot be represented in target type `i128` + --> $DIR/float_to_int_64_too_big5.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(240282366920938463463374607431768211455.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 2.4028236692093845E+38 which cannot be represented in target type `i128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big5.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big6.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big6.stderr new file mode 100644 index 0000000000..e0eab8148b --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big6.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 1.7976931348623157E+308 which cannot be represented in target type `u128` + --> $DIR/float_to_int_64_too_big6.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::MAX); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 1.7976931348623157E+308 which cannot be represented in target type `u128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big6.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_big7.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_big7.stderr new file mode 100644 index 0000000000..a291b21c7a --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_big7.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -1.7976931348623157E+308 which cannot be represented in target type `i128` + --> $DIR/float_to_int_64_too_big7.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(f64::MIN); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -1.7976931348623157E+308 which cannot be represented in target type `i128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_big7.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small1.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_small1.stderr new file mode 100644 index 0000000000..81ca218505 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -2147483649 which cannot be represented in target type `i32` + --> $DIR/float_to_int_64_too_small1.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-2147483649.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -2147483649 which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_small1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small2.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_small2.stderr new file mode 100644 index 0000000000..245f5cf023 --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -9.2233720368547778E+18 which cannot be represented in target type `i64` + --> $DIR/float_to_int_64_too_small2.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-9223372036854777856.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -9.2233720368547778E+18 which cannot be represented in target type `i64` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_small2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/float_to_int_64_too_small3.stderr b/tests/compile-fail/intrinsics/float_to_int_64_too_small3.stderr new file mode 100644 index 0000000000..f684ed2cde --- /dev/null +++ b/tests/compile-fail/intrinsics/float_to_int_64_too_small3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -2.4028236692093845E+38 which cannot be represented in target type `i128` + --> $DIR/float_to_int_64_too_small3.rs:LL:CC + | +LL | unsafe { float_to_int_unchecked::(-240282366920938463463374607431768211455.0f64); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -2.4028236692093845E+38 which cannot be represented in target type `i128` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/float_to_int_64_too_small3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/out_of_bounds_ptr_1.stderr b/tests/compile-fail/intrinsics/out_of_bounds_ptr_1.stderr new file mode 100644 index 0000000000..2b00876297 --- /dev/null +++ b/tests/compile-fail/intrinsics/out_of_bounds_ptr_1.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/out_of_bounds_ptr_1.rs:LL:CC + --> $DIR/out_of_bounds_ptr_1.rs:LL:CC + | +LL | let x = unsafe { x.offset(5) }; + | ^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.stderr b/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.stderr new file mode 100644 index 0000000000..32ac570f72 --- /dev/null +++ b/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: overflowing in-bounds pointer arithmetic + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/out_of_bounds_ptr_2.rs:LL:CC + --> $DIR/out_of_bounds_ptr_2.rs:LL:CC + | +LL | let x = unsafe { x.offset(isize::MIN) }; + | ^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/out_of_bounds_ptr_3.stderr b/tests/compile-fail/intrinsics/out_of_bounds_ptr_3.stderr new file mode 100644 index 0000000000..cd48112cb4 --- /dev/null +++ b/tests/compile-fail/intrinsics/out_of_bounds_ptr_3.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC + --> $DIR/out_of_bounds_ptr_3.rs:LL:CC + | +LL | let x = unsafe { x.offset(-1) }; + | ^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs b/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs index 730d01597f..6402f4bb74 100644 --- a/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs +++ b/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs @@ -2,7 +2,7 @@ use std::intrinsics::*; -//error-pattern: overflowing shift by 64 in `unchecked_shr` +// error-pattern: overflowing shift by 64 in `unchecked_shr` fn main() { unsafe { diff --git a/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.stderr b/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.stderr new file mode 100644 index 0000000000..0d22b166b2 --- /dev/null +++ b/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflowing shift by 64 in `unchecked_shr` + --> $DIR/overflowing-unchecked-rsh.rs:LL:CC + | +LL | let _n = unchecked_shr(1i64, 64); + | ^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/overflowing-unchecked-rsh.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_0_plus_0.stderr b/tests/compile-fail/intrinsics/ptr_offset_0_plus_0.stderr new file mode 100644 index 0000000000..d3e2fe4013 --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_0_plus_0.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::mut_ptr::::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/ptr_offset_0_plus_0.rs:LL:CC + --> $DIR/ptr_offset_0_plus_0.rs:LL:CC + | +LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds + | ^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_from_oob.stderr b/tests/compile-fail/intrinsics/ptr_offset_from_oob.stderr new file mode 100644 index 0000000000..0e723a5ee3 --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_from_oob.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds offset_from: ALLOC has size 4, so pointer at offset 10 is out-of-bounds + --> $DIR/ptr_offset_from_oob.rs:LL:CC + | +LL | unsafe { ptr_offset_from(end_ptr, end_ptr) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: ALLOC has size 4, so pointer at offset 10 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_offset_from_oob.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs b/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs index ea6bef151e..e332a9dc62 100644 --- a/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs +++ b/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs @@ -1,4 +1,4 @@ -// error-pattern: 0x1 is not a valid pointer +// error-pattern: is not a valid pointer fn main() { // Can't offset an integer pointer by non-zero offset. diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.stderr b/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.stderr new file mode 100644 index 0000000000..a47ed4719d --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: 0x1 is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::mut_ptr::::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/ptr_offset_int_plus_int.rs:LL:CC + --> $DIR/ptr_offset_int_plus_int.rs:LL:CC + | +LL | let _val = (1 as *mut u8).offset(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs b/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs index 8ff5c3596e..2d27e25a7a 100644 --- a/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs +++ b/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs @@ -1,4 +1,4 @@ -// error-pattern: 0x1 is not a valid pointer +// error-pattern: is not a valid pointer fn main() { let ptr = Box::into_raw(Box::new(0u32)); diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.stderr b/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.stderr new file mode 100644 index 0000000000..58b33e706d --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: 0x1 is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::mut_ptr::::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/ptr_offset_int_plus_ptr.rs:LL:CC + --> $DIR/ptr_offset_int_plus_ptr.rs:LL:CC + | +LL | let _val = (1 as *mut u8).offset(ptr as isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_overflow.rs b/tests/compile-fail/intrinsics/ptr_offset_overflow.rs index 452bf341c9..734547b601 100644 --- a/tests/compile-fail/intrinsics/ptr_offset_overflow.rs +++ b/tests/compile-fail/intrinsics/ptr_offset_overflow.rs @@ -1,4 +1,4 @@ -//error-pattern: overflowing in-bounds pointer arithmetic +// error-pattern: overflowing in-bounds pointer arithmetic fn main() { let v = [1i8, 2]; let x = &v[1] as *const i8; diff --git a/tests/compile-fail/intrinsics/ptr_offset_overflow.stderr b/tests/compile-fail/intrinsics/ptr_offset_overflow.stderr new file mode 100644 index 0000000000..81ff87168c --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_overflow.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: overflowing in-bounds pointer arithmetic + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/ptr_offset_overflow.rs:LL:CC + --> $DIR/ptr_offset_overflow.rs:LL:CC + | +LL | let _val = unsafe { x.offset(isize::MIN) }; + | ^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.stderr b/tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.stderr new file mode 100644 index 0000000000..686ab17966 --- /dev/null +++ b/tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: ALLOC has size 4, so pointer at offset 32 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::mut_ptr::::offset` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/ptr_offset_ptr_plus_0.rs:LL:CC + --> $DIR/ptr_offset_ptr_plus_0.rs:LL:CC + | +LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, the pointer is not inbounds of the only object it can point to + | ^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/rem-by-zero.stderr b/tests/compile-fail/intrinsics/rem-by-zero.stderr new file mode 100644 index 0000000000..7501aca7b2 --- /dev/null +++ b/tests/compile-fail/intrinsics/rem-by-zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calculating the remainder with a divisor of zero + --> $DIR/rem-by-zero.rs:LL:CC + | +LL | let _n = unchecked_rem(3u32, 0); + | ^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/rem-by-zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-div-by-zero.stderr b/tests/compile-fail/intrinsics/simd-div-by-zero.stderr new file mode 100644 index 0000000000..77c12de8d8 --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-div-by-zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dividing by zero + --> $DIR/simd-div-by-zero.rs:LL:CC + | +LL | simd_div(x, y); + | ^^^^^^^^^^^^^^ dividing by zero + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-div-by-zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-div-overflow.stderr b/tests/compile-fail/intrinsics/simd-div-overflow.stderr new file mode 100644 index 0000000000..53479a738b --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-div-overflow.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow in signed division (dividing MIN by -1) + --> $DIR/simd-div-overflow.rs:LL:CC + | +LL | simd_div(x, y); + | ^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-div-overflow.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-float-to-int.stderr b/tests/compile-fail/intrinsics/simd-float-to-int.stderr new file mode 100644 index 0000000000..378c2b48bb --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-float-to-int.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 3.40282347E+38 which cannot be represented in target type `i32` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `core::core_simd::round::>::to_int_unchecked::` at rustc_src/src/../../portable-simd/crates/core_simd/src/round.rs:LL:CC +note: inside `main` at $DIR/simd-float-to-int.rs:LL:CC + --> $DIR/simd-float-to-int.rs:LL:CC + | +LL | let _x : i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `implement` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-gather.stderr b/tests/compile-fail/intrinsics/simd-gather.stderr new file mode 100644 index 0000000000..3da14e1fe3 --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-gather.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::simd::Simd::::gather_select_unchecked` at rustc_src/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC +note: inside `main` at $DIR/simd-gather.rs:LL:CC + --> $DIR/simd-gather.rs:LL:CC + | +LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-reduce-invalid-bool.stderr b/tests/compile-fail/intrinsics/simd-reduce-invalid-bool.stderr new file mode 100644 index 0000000000..a2404b174e --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-reduce-invalid-bool.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: each element of a SIMD mask must be all-0-bits or all-1-bits + --> $DIR/simd-reduce-invalid-bool.rs:LL:CC + | +LL | simd_reduce_any(x); + | ^^^^^^^^^^^^^^^^^^ each element of a SIMD mask must be all-0-bits or all-1-bits + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-reduce-invalid-bool.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-rem-by-zero.stderr b/tests/compile-fail/intrinsics/simd-rem-by-zero.stderr new file mode 100644 index 0000000000..98e5ca2079 --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-rem-by-zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calculating the remainder with a divisor of zero + --> $DIR/simd-rem-by-zero.rs:LL:CC + | +LL | simd_rem(x, y); + | ^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-rem-by-zero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-scatter.stderr b/tests/compile-fail/intrinsics/simd-scatter.stderr new file mode 100644 index 0000000000..2d2cc2972a --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-scatter.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::simd::Simd::::scatter_select_unchecked` at rustc_src/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC +note: inside `main` at $DIR/simd-scatter.rs:LL:CC + --> $DIR/simd-scatter.rs:LL:CC + | +LL | Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(&mut vec, Mask::splat(true), idxs); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-select-bitmask-invalid.stderr b/tests/compile-fail/intrinsics/simd-select-bitmask-invalid.stderr new file mode 100644 index 0000000000..e5fe3c886c --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-select-bitmask-invalid.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits + --> $DIR/simd-select-bitmask-invalid.rs:LL:CC + | +LL | simd_select_bitmask(0b11111111u8, x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a SIMD bitmask less than 8 bits long must be filled with 0s for the remaining bits + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-select-bitmask-invalid.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-select-invalid-bool.stderr b/tests/compile-fail/intrinsics/simd-select-invalid-bool.stderr new file mode 100644 index 0000000000..f0a1282eda --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-select-invalid-bool.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: each element of a SIMD mask must be all-0-bits or all-1-bits + --> $DIR/simd-select-invalid-bool.rs:LL:CC + | +LL | simd_select(x, x, x); + | ^^^^^^^^^^^^^^^^^^^^ each element of a SIMD mask must be all-0-bits or all-1-bits + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-select-invalid-bool.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-shl-too-far.stderr b/tests/compile-fail/intrinsics/simd-shl-too-far.stderr new file mode 100644 index 0000000000..dcd38d6f01 --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-shl-too-far.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflowing shift by 100 in `simd_shl` in SIMD lane 0 + --> $DIR/simd-shl-too-far.rs:LL:CC + | +LL | simd_shl(x, y); + | ^^^^^^^^^^^^^^ overflowing shift by 100 in `simd_shl` in SIMD lane 0 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-shl-too-far.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/simd-shr-too-far.stderr b/tests/compile-fail/intrinsics/simd-shr-too-far.stderr new file mode 100644 index 0000000000..c2c2850522 --- /dev/null +++ b/tests/compile-fail/intrinsics/simd-shr-too-far.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflowing shift by 40 in `simd_shr` in SIMD lane 1 + --> $DIR/simd-shr-too-far.rs:LL:CC + | +LL | simd_shr(x, y); + | ^^^^^^^^^^^^^^ overflowing shift by 40 in `simd_shr` in SIMD lane 1 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/simd-shr-too-far.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_add1.stderr b/tests/compile-fail/intrinsics/unchecked_add1.stderr new file mode 100644 index 0000000000..b967b46ac9 --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_add1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_add` + --> $DIR/unchecked_add1.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_add(40000u16, 30000); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_add1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_add2.stderr b/tests/compile-fail/intrinsics/unchecked_add2.stderr new file mode 100644 index 0000000000..18a116b7da --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_add2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_add` + --> $DIR/unchecked_add2.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_add(-30000i16, -8000); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_add2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_div1.stderr b/tests/compile-fail/intrinsics/unchecked_div1.stderr new file mode 100644 index 0000000000..f153e4efd9 --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_div1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow in signed division (dividing MIN by -1) + --> $DIR/unchecked_div1.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed division (dividing MIN by -1) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_div1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_mul1.stderr b/tests/compile-fail/intrinsics/unchecked_mul1.stderr new file mode 100644 index 0000000000..5372ba9933 --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_mul1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_mul` + --> $DIR/unchecked_mul1.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_mul(300u16, 250u16); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_mul1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_mul2.stderr b/tests/compile-fail/intrinsics/unchecked_mul2.stderr new file mode 100644 index 0000000000..20a44d2422 --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_mul2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_mul` + --> $DIR/unchecked_mul2.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_mul(1_000_000_000i32, -4); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_mul2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_sub1.stderr b/tests/compile-fail/intrinsics/unchecked_sub1.stderr new file mode 100644 index 0000000000..12abfed8ff --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_sub1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_sub` + --> $DIR/unchecked_sub1.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_sub(14u32, 22); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_sub1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/unchecked_sub2.stderr b/tests/compile-fail/intrinsics/unchecked_sub2.stderr new file mode 100644 index 0000000000..d62d2de2f9 --- /dev/null +++ b/tests/compile-fail/intrinsics/unchecked_sub2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: overflow executing `unchecked_sub` + --> $DIR/unchecked_sub2.rs:LL:CC + | +LL | unsafe { std::intrinsics::unchecked_sub(30000i16, -7000); } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unchecked_sub2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/uninit_uninhabited_type.stderr b/tests/compile-fail/intrinsics/uninit_uninhabited_type.stderr new file mode 100644 index 0000000000..150128ba2a --- /dev/null +++ b/tests/compile-fail/intrinsics/uninit_uninhabited_type.stderr @@ -0,0 +1,12 @@ +error: abnormal termination: aborted execution: attempted to instantiate uninhabited type `!` + --> $DIR/uninit_uninhabited_type.rs:LL:CC + | +LL | unsafe { std::mem::uninitialized::() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` + | + = note: inside `main` at $DIR/uninit_uninhabited_type.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/write_bytes_null.stderr b/tests/compile-fail/intrinsics/write_bytes_null.stderr new file mode 100644 index 0000000000..77f675e8fb --- /dev/null +++ b/tests/compile-fail/intrinsics/write_bytes_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: memory access failed: null pointer is not a valid pointer + --> $DIR/write_bytes_null.rs:LL:CC + | +LL | unsafe { write_bytes::(std::ptr::null_mut(), 0, 0) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/write_bytes_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/write_bytes_overflow.stderr b/tests/compile-fail/intrinsics/write_bytes_overflow.stderr new file mode 100644 index 0000000000..018ba83f53 --- /dev/null +++ b/tests/compile-fail/intrinsics/write_bytes_overflow.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: overflow computing total size of `write_bytes` + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::intrinsics::write_bytes::` at rustc_src/src/intrinsics.rs:LL:CC + = note: inside `std::ptr::mut_ptr::::write_bytes` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC + --> $DIR/write_bytes_overflow.rs:LL:CC + | +LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::() * 8 - 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/intrinsics/zero_fn_ptr.stderr b/tests/compile-fail/intrinsics/zero_fn_ptr.stderr new file mode 100644 index 0000000000..9d44ba9f74 --- /dev/null +++ b/tests/compile-fail/intrinsics/zero_fn_ptr.stderr @@ -0,0 +1,12 @@ +error: abnormal termination: aborted execution: attempted to zero-initialize type `fn()`, which is invalid + --> $DIR/zero_fn_ptr.rs:LL:CC + | +LL | unsafe { std::mem::zeroed::() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `fn()`, which is invalid + | + = note: inside `main` at $DIR/zero_fn_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/invalid_bool.rs b/tests/compile-fail/invalid_bool.rs index 22b9de5776..c0c982b8ca 100644 --- a/tests/compile-fail/invalid_bool.rs +++ b/tests/compile-fail/invalid_bool.rs @@ -5,5 +5,5 @@ fn main() { let b = unsafe { std::mem::transmute::(2) }; - let _x = b == std::hint::black_box(true); //~ ERROR interpreting an invalid 8-bit value as a bool: 0x02 + let _x = b == std::hint::black_box(true); //~ ERROR interpreting an invalid 8-bit value as a bool } diff --git a/tests/compile-fail/invalid_bool.stderr b/tests/compile-fail/invalid_bool.stderr new file mode 100644 index 0000000000..23c5365618 --- /dev/null +++ b/tests/compile-fail/invalid_bool.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: interpreting an invalid 8-bit value as a bool: 0x02 + --> $DIR/invalid_bool.rs:LL:CC + | +LL | let _x = b == std::hint::black_box(true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x02 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_bool.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/invalid_char.rs b/tests/compile-fail/invalid_char.rs index b240cb22eb..9d485b73f2 100644 --- a/tests/compile-fail/invalid_char.rs +++ b/tests/compile-fail/invalid_char.rs @@ -6,5 +6,5 @@ fn main() { let c = 0xFFFFFFu32; assert!(std::char::from_u32(c).is_none()); let c = unsafe { std::mem::transmute::(c) }; - let _x = c == 'x'; //~ ERROR interpreting an invalid 32-bit value as a char: 0x00ffffff + let _x = c == 'x'; //~ ERROR interpreting an invalid 32-bit value as a char } diff --git a/tests/compile-fail/invalid_char.stderr b/tests/compile-fail/invalid_char.stderr new file mode 100644 index 0000000000..69f3ef1f4a --- /dev/null +++ b/tests/compile-fail/invalid_char.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: interpreting an invalid 32-bit value as a char: $HEX + --> $DIR/invalid_char.rs:LL:CC + | +LL | let _x = c == 'x'; + | ^^^^^^^^ interpreting an invalid 32-bit value as a char: $HEX + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_char.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/invalid_enum_tag.rs b/tests/compile-fail/invalid_enum_tag.rs index 762a70d803..63b6003f3d 100644 --- a/tests/compile-fail/invalid_enum_tag.rs +++ b/tests/compile-fail/invalid_enum_tag.rs @@ -2,7 +2,7 @@ // Make sure we find these even with many checks disabled. // compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation -// error-pattern: enum value has invalid tag: 0x0000002a +// error-pattern: enum value has invalid tag use std::mem; diff --git a/tests/compile-fail/invalid_enum_tag.stderr b/tests/compile-fail/invalid_enum_tag.stderr new file mode 100644 index 0000000000..a602204cf4 --- /dev/null +++ b/tests/compile-fail/invalid_enum_tag.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: enum value has invalid tag: $HEX + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::mem::discriminant::` at rustc_src/src/mem/mod.rs:LL:CC +note: inside `main` at $DIR/invalid_enum_tag.rs:LL:CC + --> $DIR/invalid_enum_tag.rs:LL:CC + | +LL | let _val = mem::discriminant(&f); + | ^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/invalid_int.stderr b/tests/compile-fail/invalid_int.stderr new file mode 100644 index 0000000000..cd7919444f --- /dev/null +++ b/tests/compile-fail/invalid_int.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/invalid_int.rs:LL:CC + | +LL | let _x = i + 0; + | ^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_int.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/issue-miri-1112.stderr b/tests/compile-fail/issue-miri-1112.stderr new file mode 100644 index 0000000000..1dfcad0c14 --- /dev/null +++ b/tests/compile-fail/issue-miri-1112.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: type validation failed: encountered invalid drop function pointer in vtable (function has incompatible signature) + --> $DIR/issue-miri-1112.rs:LL:CC + | +LL | let obj = std::mem::transmute::(obj); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop function pointer in vtable (function has incompatible signature) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `FunnyPointer::from_data_ptr` at $DIR/issue-miri-1112.rs:LL:CC +note: inside `main` at $DIR/issue-miri-1112.rs:LL:CC + --> $DIR/issue-miri-1112.rs:LL:CC + | +LL | let _raw: &FunnyPointer = FunnyPointer::from_data_ptr(&hello, &meta as *const _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/memleak.rs b/tests/compile-fail/memleak.rs index 71b4e2f442..7dee9ddf1c 100644 --- a/tests/compile-fail/memleak.rs +++ b/tests/compile-fail/memleak.rs @@ -1,4 +1,5 @@ -//error-pattern: the evaluated program leaked memory +// error-pattern: the evaluated program leaked memory +// normalize-stderr-test: ".*│.*" -> "$$stripped$$" fn main() { std::mem::forget(Box::new(42)); diff --git a/tests/compile-fail/memleak.stderr b/tests/compile-fail/memleak.stderr new file mode 100644 index 0000000000..f8b62af3eb --- /dev/null +++ b/tests/compile-fail/memleak.stderr @@ -0,0 +1,10 @@ +The following memory was leaked: ALLOC (Rust heap, size: 4, align: 4) { +$stripped$ +} + +error: the evaluated program leaked memory + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error + diff --git a/tests/compile-fail/memleak_rc.32bit.stderr b/tests/compile-fail/memleak_rc.32bit.stderr new file mode 100644 index 0000000000..da22260909 --- /dev/null +++ b/tests/compile-fail/memleak_rc.32bit.stderr @@ -0,0 +1,10 @@ +The following memory was leaked: ALLOC (Rust heap, size: 16, align: 4) { +$stripped$ +} + +error: the evaluated program leaked memory + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error + diff --git a/tests/compile-fail/memleak_rc.64bit.stderr b/tests/compile-fail/memleak_rc.64bit.stderr new file mode 100644 index 0000000000..8c24bbc779 --- /dev/null +++ b/tests/compile-fail/memleak_rc.64bit.stderr @@ -0,0 +1,11 @@ +The following memory was leaked: ALLOC (Rust heap, size: 32, align: 8) { +$stripped$ +$stripped$ +} + +error: the evaluated program leaked memory + +note: pass `-Zmiri-ignore-leaks` to disable this check + +error: aborting due to previous error + diff --git a/tests/compile-fail/memleak_rc.rs b/tests/compile-fail/memleak_rc.rs index b2bc6722af..17bcb36f36 100644 --- a/tests/compile-fail/memleak_rc.rs +++ b/tests/compile-fail/memleak_rc.rs @@ -1,4 +1,6 @@ -//error-pattern: the evaluated program leaked memory +// error-pattern: the evaluated program leaked memory +// stderr-per-bitwidth +// normalize-stderr-test: ".*│.*" -> "$$stripped$$" use std::rc::Rc; use std::cell::RefCell; diff --git a/tests/compile-fail/modifying_constants.stderr b/tests/compile-fail/modifying_constants.stderr new file mode 100644 index 0000000000..9950114823 --- /dev/null +++ b/tests/compile-fail/modifying_constants.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/modifying_constants.rs:LL:CC + | +LL | *y = 42; + | ^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/modifying_constants.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/never_say_never.stderr b/tests/compile-fail/never_say_never.stderr new file mode 100644 index 0000000000..22ad10f131 --- /dev/null +++ b/tests/compile-fail/never_say_never.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: entering unreachable code + --> $DIR/never_say_never.rs:LL:CC + | +LL | *(y as *const _ as *const !) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/never_say_never.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/never_transmute_humans.stderr b/tests/compile-fail/never_transmute_humans.stderr new file mode 100644 index 0000000000..6d8fa37e98 --- /dev/null +++ b/tests/compile-fail/never_transmute_humans.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: transmuting to uninhabited type + --> $DIR/never_transmute_humans.rs:LL:CC + | +LL | std::mem::transmute::(Human) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/never_transmute_humans.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/never_transmute_void.stderr b/tests/compile-fail/never_transmute_void.stderr new file mode 100644 index 0000000000..8d8a4d0e83 --- /dev/null +++ b/tests/compile-fail/never_transmute_void.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: entering unreachable code + --> $DIR/never_transmute_void.rs:LL:CC + | +LL | match v.0 {} + | ^^^ entering unreachable code + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `m::f` at $DIR/never_transmute_void.rs:LL:CC +note: inside `main` at $DIR/never_transmute_void.rs:LL:CC + --> $DIR/never_transmute_void.rs:LL:CC + | +LL | m::f(v); + | ^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/no_main.stderr b/tests/compile-fail/no_main.stderr new file mode 100644 index 0000000000..52591a8d6d --- /dev/null +++ b/tests/compile-fail/no_main.stderr @@ -0,0 +1,2 @@ +error: miri can only run programs that have a main function + diff --git a/tests/compile-fail/null_pointer_deref.stderr b/tests/compile-fail/null_pointer_deref.stderr new file mode 100644 index 0000000000..0930160023 --- /dev/null +++ b/tests/compile-fail/null_pointer_deref.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_deref.rs:LL:CC + | +LL | let x: i32 = unsafe { *std::ptr::null() }; + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_deref.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/null_pointer_deref_zst.stderr b/tests/compile-fail/null_pointer_deref_zst.stderr new file mode 100644 index 0000000000..25fea50b15 --- /dev/null +++ b/tests/compile-fail/null_pointer_deref_zst.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_deref_zst.rs:LL:CC + | +LL | let x: () = unsafe { *std::ptr::null() }; + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_deref_zst.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/null_pointer_write.stderr b/tests/compile-fail/null_pointer_write.stderr new file mode 100644 index 0000000000..5ac8cc7c20 --- /dev/null +++ b/tests/compile-fail/null_pointer_write.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: null pointer is not a valid pointer + --> $DIR/null_pointer_write.rs:LL:CC + | +LL | unsafe { *std::ptr::null_mut() = 0i32 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/null_pointer_write.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/null_pointer_write_zst.stderr b/tests/compile-fail/null_pointer_write_zst.stderr new file mode 100644 index 0000000000..b40a9154f1 --- /dev/null +++ b/tests/compile-fail/null_pointer_write_zst.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: memory access failed: null pointer is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::write::<[u8; 0]>` at rustc_src/src/ptr/mod.rs:LL:CC + = note: inside `std::ptr::mut_ptr::::write` at rustc_src/src/ptr/mut_ptr.rs:LL:CC +note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC + --> $DIR/null_pointer_write_zst.rs:LL:CC + | +LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/bad_miri_start_panic.stderr b/tests/compile-fail/panic/bad_miri_start_panic.stderr new file mode 100644 index 0000000000..dca5d39b76 --- /dev/null +++ b/tests/compile-fail/panic/bad_miri_start_panic.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding + --> $DIR/bad_miri_start_panic.rs:LL:CC + | +LL | unsafe { miri_start_panic(&mut 0) } + | ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/bad_miri_start_panic.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/bad_unwind.stderr b/tests/compile-fail/panic/bad_unwind.stderr new file mode 100644 index 0000000000..529f4179a8 --- /dev/null +++ b/tests/compile-fail/panic/bad_unwind.stderr @@ -0,0 +1,25 @@ +thread 'main' panicked at 'explicit panic', $DIR/bad_unwind.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding + --> $DIR/bad_unwind.rs:LL:CC + | +LL | std::panic::catch_unwind(|| unwind()).unwrap_err(); + | ^^^^^^^^ unwinding past a stack frame that does not allow unwinding + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/bad_unwind.rs:LL:CC + = note: inside `std::panicking::r#try::do_call::<[closure@$DIR/bad_unwind.rs:LL:CC: 13:41], ()>` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panicking::r#try::<(), [closure@$DIR/bad_unwind.rs:LL:CC: 13:41]>` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panic::catch_unwind::<[closure@$DIR/bad_unwind.rs:LL:CC: 13:41], ()>` at rustc_src/src/panic.rs:LL:CC +note: inside `main` at $DIR/bad_unwind.rs:LL:CC + --> $DIR/bad_unwind.rs:LL:CC + | +LL | std::panic::catch_unwind(|| unwind()).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/double_panic.stderr b/tests/compile-fail/panic/double_panic.stderr new file mode 100644 index 0000000000..b854a6b721 --- /dev/null +++ b/tests/compile-fail/panic/double_panic.stderr @@ -0,0 +1,91 @@ +thread 'main' panicked at 'first', $DIR/double_panic.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +thread 'main' panicked at 'second', $DIR/double_panic.rs:LL:CC +stack backtrace: + 0: std::backtrace_rs::backtrace::miri::trace_unsynchronized + at rustc_src/src/../../backtrace/src/backtrace/miri.rs:LL:CC + 1: std::backtrace_rs::backtrace::miri::trace + at rustc_src/src/../../backtrace/src/backtrace/miri.rs:LL:CC + 2: std::backtrace_rs::backtrace::trace_unsynchronized + at rustc_src/src/../../backtrace/src/backtrace/mod.rs:LL:CC + 3: std::sys_common::backtrace::_print_fmt + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 4: ::fmt + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 5: std::fmt::write + at rustc_src/src/fmt/mod.rs:LL:CC + 6: ::write_fmt + at rustc_src/src/io/mod.rs:LL:CC + 7: std::sys_common::backtrace::_print + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 8: std::sys_common::backtrace::print + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 9: std::panicking::default_hook::{closure#1} + at rustc_src/src/panicking.rs:LL:CC + 10: std::panicking::default_hook + at rustc_src/src/panicking.rs:LL:CC + 11: std::panicking::rust_panic_with_hook + at rustc_src/src/panicking.rs:LL:CC + 12: std::rt::begin_panic::{closure#0} + at rustc_src/src/panicking.rs:LL:CC + 13: std::sys_common::backtrace::__rust_end_short_backtrace + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 14: std::rt::begin_panic + at rustc_src/src/panicking.rs:LL:CC + 15: ::drop + at $DIR/double_panic.rs:LL:CC + 16: std::ptr::drop_in_place - shim(Some(Foo)) + at rustc_src/src/ptr/mod.rs:LL:CC + 17: main + at $DIR/double_panic.rs:LL:CC + 18: >::call_once - shim(fn()) + at rustc_src/src/ops/function.rs:LL:CC + 19: std::sys_common::backtrace::__rust_begin_short_backtrace + at rustc_src/src/sys_common/backtrace.rs:LL:CC + 20: std::rt::lang_start::{closure#0} + at rustc_src/src/rt.rs:LL:CC + 21: std::ops::function::impls::call_once + at rustc_src/src/ops/function.rs:LL:CC + 22: std::panicking::r#try::do_call + at rustc_src/src/panicking.rs:LL:CC + 23: std::panicking::r#try + at rustc_src/src/panicking.rs:LL:CC + 24: std::panic::catch_unwind + at rustc_src/src/panic.rs:LL:CC + 25: std::rt::lang_start_internal::{closure#2} + at rustc_src/src/rt.rs:LL:CC + 26: std::panicking::r#try::do_call + at rustc_src/src/panicking.rs:LL:CC + 27: std::panicking::r#try + at rustc_src/src/panicking.rs:LL:CC + 28: std::panic::catch_unwind + at rustc_src/src/panic.rs:LL:CC + 29: std::rt::lang_start_internal + at rustc_src/src/rt.rs:LL:CC + 30: std::rt::lang_start + at rustc_src/src/rt.rs:LL:CC +thread panicked while panicking. aborting. +error: abnormal termination: the program aborted execution + | + = note: inside `std::sys::PLATFORM::abort_internal` at rustc_src/src/sys/PLATFORM/mod.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at rustc_src/src/panicking.rs:LL:CC + = note: inside closure at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>` at rustc_src/src/sys_common/backtrace.rs:LL:CC + = note: inside `std::rt::begin_panic::<&str>` at rustc_src/src/panicking.rs:LL:CC +note: inside `::drop` at rustc_src/src/panic.rs:LL:CC + --> $DIR/double_panic.rs:LL:CC + | +LL | panic!("second"); + | ^^^^^^^^^^^^^^^^ + = note: inside `std::ptr::drop_in_place:: - shim(Some(Foo))` at rustc_src/src/ptr/mod.rs:LL:CC +note: inside `main` at $DIR/double_panic.rs:LL:CC + --> $DIR/double_panic.rs:LL:CC + | +LL | } + | ^ + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/panic_abort1.stderr b/tests/compile-fail/panic/panic_abort1.stderr new file mode 100644 index 0000000000..93f48bb89e --- /dev/null +++ b/tests/compile-fail/panic/panic_abort1.stderr @@ -0,0 +1,22 @@ +thread 'main' panicked at 'panicking from libstd', $DIR/panic_abort1.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + | + = note: inside `panic_abort::__rust_start_panic::abort` at rustc_src/src/lib.rs:LL:CC + = note: inside `panic_abort::__rust_start_panic` at rustc_src/src/lib.rs:LL:CC + = note: inside `std::panicking::rust_panic` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at rustc_src/src/panicking.rs:LL:CC + = note: inside closure at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>` at rustc_src/src/sys_common/backtrace.rs:LL:CC + = note: inside `std::rt::begin_panic::<&str>` at rustc_src/src/panicking.rs:LL:CC +note: inside `main` at rustc_src/src/panic.rs:LL:CC + --> $DIR/panic_abort1.rs:LL:CC + | +LL | std::panic!("panicking from libstd"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/panic_abort2.stderr b/tests/compile-fail/panic/panic_abort2.stderr new file mode 100644 index 0000000000..bb4b96fd0a --- /dev/null +++ b/tests/compile-fail/panic/panic_abort2.stderr @@ -0,0 +1,23 @@ +thread 'main' panicked at '42-panicking from libstd', $DIR/panic_abort2.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + | + = note: inside `panic_abort::__rust_start_panic::abort` at rustc_src/src/lib.rs:LL:CC + = note: inside `panic_abort::__rust_start_panic` at rustc_src/src/lib.rs:LL:CC + = note: inside `std::panicking::rust_panic` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at rustc_src/src/panicking.rs:LL:CC + = note: inside closure at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at rustc_src/src/sys_common/backtrace.rs:LL:CC + = note: inside `std::panicking::begin_panic_handler` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::rt::panic_fmt` at rustc_src/src/panicking.rs:LL:CC +note: inside `main` at rustc_src/src/panic.rs:LL:CC + --> $DIR/panic_abort2.rs:LL:CC + | +LL | std::panic!("{}-panicking from libstd", 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/panic_abort3.stderr b/tests/compile-fail/panic/panic_abort3.stderr new file mode 100644 index 0000000000..a799ce4b4d --- /dev/null +++ b/tests/compile-fail/panic/panic_abort3.stderr @@ -0,0 +1,24 @@ +thread 'main' panicked at 'panicking from libcore', $DIR/panic_abort3.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + | + = note: inside `panic_abort::__rust_start_panic::abort` at rustc_src/src/lib.rs:LL:CC + = note: inside `panic_abort::__rust_start_panic` at rustc_src/src/lib.rs:LL:CC + = note: inside `std::panicking::rust_panic` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at rustc_src/src/panicking.rs:LL:CC + = note: inside closure at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at rustc_src/src/sys_common/backtrace.rs:LL:CC + = note: inside `std::panicking::begin_panic_handler` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::rt::panic_fmt` at rustc_src/src/panicking.rs:LL:CC + = note: inside `core::panicking::panic` at rustc_src/src/panicking.rs:LL:CC +note: inside `main` at rustc_src/src/panic.rs:LL:CC + --> $DIR/panic_abort3.rs:LL:CC + | +LL | core::panic!("panicking from libcore"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/panic_abort4.stderr b/tests/compile-fail/panic/panic_abort4.stderr new file mode 100644 index 0000000000..a24d0948d1 --- /dev/null +++ b/tests/compile-fail/panic/panic_abort4.stderr @@ -0,0 +1,23 @@ +thread 'main' panicked at '42-panicking from libcore', $DIR/panic_abort4.rs:LL:CC +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +error: abnormal termination: the program aborted execution + | + = note: inside `panic_abort::__rust_start_panic::abort` at rustc_src/src/lib.rs:LL:CC + = note: inside `panic_abort::__rust_start_panic` at rustc_src/src/lib.rs:LL:CC + = note: inside `std::panicking::rust_panic` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::panicking::rust_panic_with_hook` at rustc_src/src/panicking.rs:LL:CC + = note: inside closure at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at rustc_src/src/sys_common/backtrace.rs:LL:CC + = note: inside `std::panicking::begin_panic_handler` at rustc_src/src/panicking.rs:LL:CC + = note: inside `std::rt::panic_fmt` at rustc_src/src/panicking.rs:LL:CC +note: inside `main` at rustc_src/src/panic.rs:LL:CC + --> $DIR/panic_abort4.rs:LL:CC + | +LL | core::panic!("{}-panicking from libcore", 42); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/panic/unwind_panic_abort.stderr b/tests/compile-fail/panic/unwind_panic_abort.stderr new file mode 100644 index 0000000000..7ae965156f --- /dev/null +++ b/tests/compile-fail/panic/unwind_panic_abort.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding + --> $DIR/unwind_panic_abort.rs:LL:CC + | +LL | unsafe { miri_start_panic(&mut 0); } + | ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unwind_panic_abort.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/pointer_partial_overwrite.stderr b/tests/compile-fail/pointer_partial_overwrite.stderr new file mode 100644 index 0000000000..6779df99c3 --- /dev/null +++ b/tests/compile-fail/pointer_partial_overwrite.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/pointer_partial_overwrite.rs:LL:CC + | +LL | let x = *p; + | ^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/pointer_partial_overwrite.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/pointer_partial_read.stderr b/tests/compile-fail/pointer_partial_read.stderr new file mode 100644 index 0000000000..dc35f7e109 --- /dev/null +++ b/tests/compile-fail/pointer_partial_read.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unable to turn pointer into raw bytes + --> $DIR/pointer_partial_read.rs:LL:CC + | +LL | let _val = unsafe { *z }; + | ^^ unable to turn pointer into raw bytes + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/pointer_partial_read.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/provenance/ptr_int_unexposed.stderr b/tests/compile-fail/provenance/ptr_int_unexposed.stderr new file mode 100644 index 0000000000..cdd25d0e63 --- /dev/null +++ b/tests/compile-fail/provenance/ptr_int_unexposed.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: $HEX is not a valid pointer + --> $DIR/ptr_int_unexposed.rs:LL:CC + | +LL | assert_eq!(unsafe { *ptr }, 3); + | ^^^^ dereferencing pointer failed: $HEX is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_int_unexposed.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/provenance/ptr_invalid.stderr b/tests/compile-fail/provenance/ptr_invalid.stderr new file mode 100644 index 0000000000..76a40765eb --- /dev/null +++ b/tests/compile-fail/provenance/ptr_invalid.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: $HEX is not a valid pointer + --> $DIR/ptr_invalid.rs:LL:CC + | +LL | let _val = unsafe { *xptr_invalid }; + | ^^^^^^^^^^^^^ dereferencing pointer failed: $HEX is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_invalid.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/provenance/ptr_legacy_provenance.rs b/tests/compile-fail/provenance/ptr_legacy_provenance.rs index aecc1460e0..538ec4484e 100644 --- a/tests/compile-fail/provenance/ptr_legacy_provenance.rs +++ b/tests/compile-fail/provenance/ptr_legacy_provenance.rs @@ -1,4 +1,5 @@ // compile-flags: -Zmiri-disable-stacked-borrows +// normalize-stderr-test: "offset -[0-9]+" -> "offset -XX" #![feature(strict_provenance)] use std::ptr; diff --git a/tests/compile-fail/provenance/ptr_legacy_provenance.stderr b/tests/compile-fail/provenance/ptr_legacy_provenance.stderr new file mode 100644 index 0000000000..4552be0814 --- /dev/null +++ b/tests/compile-fail/provenance/ptr_legacy_provenance.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 4, so pointer to 4 bytes starting at offset -XX is out-of-bounds + --> $DIR/ptr_legacy_provenance.rs:LL:CC + | +LL | assert_eq!(unsafe { *ptr }, 0); + | ^^^^ dereferencing pointer failed: ALLOC has size 4, so pointer to 4 bytes starting at offset -XX is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_legacy_provenance.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/provenance/strict-provenance-offset.stderr b/tests/compile-fail/provenance/strict-provenance-offset.stderr new file mode 100644 index 0000000000..482b7a404c --- /dev/null +++ b/tests/compile-fail/provenance/strict-provenance-offset.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: $HEX is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/strict-provenance-offset.rs:LL:CC + --> $DIR/strict-provenance-offset.rs:LL:CC + | +LL | let _ = unsafe { roundtrip.offset(1) }; + | ^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/provenance/strict_provenance_transmute.stderr b/tests/compile-fail/provenance/strict_provenance_transmute.stderr new file mode 100644 index 0000000000..544431815c --- /dev/null +++ b/tests/compile-fail/provenance/strict_provenance_transmute.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: type validation failed: encountered pointer to $HEX[ALLOC], but expected plain (non-pointer) bytes + --> $DIR/strict_provenance_transmute.rs:LL:CC + | +LL | let left_int: usize = mem::transmute(left); + | ^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to $HEX[ALLOC], but expected plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `deref` at $DIR/strict_provenance_transmute.rs:LL:CC +note: inside `main` at $DIR/strict_provenance_transmute.rs:LL:CC + --> $DIR/strict_provenance_transmute.rs:LL:CC + | +LL | deref(ptr1, ptr2.with_addr(ptr1.addr())); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/ptr_integer_array_transmute.stderr b/tests/compile-fail/ptr_integer_array_transmute.stderr new file mode 100644 index 0000000000..bc2ca54438 --- /dev/null +++ b/tests/compile-fail/ptr_integer_array_transmute.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a pointer, but expected plain (non-pointer) bytes + --> $DIR/ptr_integer_array_transmute.rs:LL:CC + | +LL | let _i: [usize; 1] = unsafe { std::mem::transmute(r) }; + | ^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_integer_array_transmute.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/ptr_integer_transmute.stderr b/tests/compile-fail/ptr_integer_transmute.stderr new file mode 100644 index 0000000000..de9ebf4eb0 --- /dev/null +++ b/tests/compile-fail/ptr_integer_transmute.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered pointer to $HEX[ALLOC], but expected initialized plain (non-pointer) bytes + --> $DIR/ptr_integer_transmute.rs:LL:CC + | +LL | let _i: usize = unsafe { std::mem::transmute(r) }; + | ^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to $HEX[ALLOC], but expected initialized plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_integer_transmute.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/rc_as_ptr.stderr b/tests/compile-fail/rc_as_ptr.stderr new file mode 100644 index 0000000000..3d745b7dc5 --- /dev/null +++ b/tests/compile-fail/rc_as_ptr.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/rc_as_ptr.rs:LL:CC + | +LL | assert_eq!(42, **unsafe { &*Weak::as_ptr(&weak) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at rustc_src/src/macros/mod.rs:LL:CC + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/reading_half_a_pointer.stderr b/tests/compile-fail/reading_half_a_pointer.stderr new file mode 100644 index 0000000000..505c8deafb --- /dev/null +++ b/tests/compile-fail/reading_half_a_pointer.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unable to turn pointer into raw bytes + --> $DIR/reading_half_a_pointer.rs:LL:CC + | +LL | let _x = *d_alias; + | ^^^^^^^^ unable to turn pointer into raw bytes + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/reading_half_a_pointer.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/rustc-error.stderr b/tests/compile-fail/rustc-error.stderr new file mode 100644 index 0000000000..09d0f7a6df --- /dev/null +++ b/tests/compile-fail/rustc-error.stderr @@ -0,0 +1,14 @@ +error[E0423]: expected function, found macro `println` + --> $DIR/rustc-error.rs:LL:CC + | +LL | println("Hello, world!"); + | ^^^^^^^ not a function + | +help: use `!` to invoke the macro + | +LL | println!("Hello, world!"); + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0423`. diff --git a/tests/compile-fail/shim_arg_size.32bit.stderr b/tests/compile-fail/shim_arg_size.32bit.stderr new file mode 100644 index 0000000000..3b54a5b512 --- /dev/null +++ b/tests/compile-fail/shim_arg_size.32bit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: scalar size mismatch: expected 4 bytes but got 2 bytes instead + --> $DIR/shim_arg_size.rs:LL:CC + | +LL | let _p1 = malloc(42); + | ^^^^^^^^^^ scalar size mismatch: expected 4 bytes but got 2 bytes instead + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/shim_arg_size.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/shim_arg_size.64bit.stderr b/tests/compile-fail/shim_arg_size.64bit.stderr new file mode 100644 index 0000000000..5e33604c12 --- /dev/null +++ b/tests/compile-fail/shim_arg_size.64bit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: scalar size mismatch: expected 8 bytes but got 4 bytes instead + --> $DIR/shim_arg_size.rs:LL:CC + | +LL | let _p1 = malloc(42); + | ^^^^^^^^^^ scalar size mismatch: expected 8 bytes but got 4 bytes instead + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/shim_arg_size.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/shim_arg_size.rs b/tests/compile-fail/shim_arg_size.rs index 556195d6e9..1297e5ed07 100644 --- a/tests/compile-fail/shim_arg_size.rs +++ b/tests/compile-fail/shim_arg_size.rs @@ -1,3 +1,5 @@ +// stderr-per-bitwidth + fn main() { extern "C" { // Use the wrong type(ie. not the pointer width) for the `size` diff --git a/tests/compile-fail/slice-too-big.stderr b/tests/compile-fail/slice-too-big.stderr new file mode 100644 index 0000000000..13239506c6 --- /dev/null +++ b/tests/compile-fail/slice-too-big.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/slice-too-big.rs:5:21 + | +LL | let _x: &[u8] = mem::transmute((ptr, usize::MAX)); //~ ERROR: invalid reference metadata: slice is bigger than largest supported object + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/slice-too-big.rs:5:21 + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/alias_through_mutation.stderr b/tests/compile-fail/stacked_borrows/alias_through_mutation.stderr new file mode 100644 index 0000000000..6862a67fae --- /dev/null +++ b/tests/compile-fail/stacked_borrows/alias_through_mutation.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/alias_through_mutation.rs:LL:CC + | +LL | let _val = *target_alias; + | ^^^^^^^^^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/alias_through_mutation.rs:LL:CC + | +LL | unsafe { *x = &mut *(target as *mut _); } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/alias_through_mutation.rs:LL:CC + | +LL | *target = 13; + | ^^^^^^^^^^^^ + = note: inside `main` at $DIR/alias_through_mutation.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/aliasing_mut1.stderr b/tests/compile-fail/stacked_borrows/aliasing_mut1.stderr new file mode 100644 index 0000000000..5f2e5cbbad --- /dev/null +++ b/tests/compile-fail/stacked_borrows/aliasing_mut1.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [Unique for (call ID)] + --> $DIR/aliasing_mut1.rs:LL:CC + | +LL | pub fn safe(_x: &mut i32, _y: &mut i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag because incompatible item is protected: [Unique for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/aliasing_mut1.rs:LL:CC + | +LL | let xraw: *mut i32 = unsafe { mem::transmute(&mut x) }; + | ^^^^^^ +help: was protected due to which was created here + --> $DIR/aliasing_mut1.rs:LL:CC + | +LL | let xraw: *mut i32 = unsafe { mem::transmute(&mut x) }; + | ^^^^^^ +help: this protector is live for this call + --> $DIR/aliasing_mut1.rs:LL:CC + | +LL | pub fn safe(_x: &mut i32, _y: &mut i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `safe` at $DIR/aliasing_mut1.rs:LL:CC +note: inside `main` at $DIR/aliasing_mut1.rs:LL:CC + --> $DIR/aliasing_mut1.rs:LL:CC + | +LL | safe_raw(xraw, xraw); + | ^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/aliasing_mut2.stderr b/tests/compile-fail/stacked_borrows/aliasing_mut2.stderr new file mode 100644 index 0000000000..bb82252e78 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/aliasing_mut2.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + --> $DIR/aliasing_mut2.rs:LL:CC + | +LL | pub fn safe(_x: &i32, _y: &mut i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/aliasing_mut2.rs:LL:CC + | +LL | let xref = &mut x; + | ^^^^^^ +help: was protected due to which was created here + --> $DIR/aliasing_mut2.rs:LL:CC + | +LL | safe_raw(xshr, xraw); + | ^^^^ +help: this protector is live for this call + --> $DIR/aliasing_mut2.rs:LL:CC + | +LL | pub fn safe(_x: &i32, _y: &mut i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `safe` at $DIR/aliasing_mut2.rs:LL:CC +note: inside `main` at $DIR/aliasing_mut2.rs:LL:CC + --> $DIR/aliasing_mut2.rs:LL:CC + | +LL | safe_raw(xshr, xraw); + | ^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/aliasing_mut3.stderr b/tests/compile-fail/stacked_borrows/aliasing_mut3.stderr new file mode 100644 index 0000000000..0cfddcac84 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/aliasing_mut3.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/aliasing_mut3.rs:LL:CC + | +LL | pub fn safe(_x: &mut i32, _y: &i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/aliasing_mut3.rs:LL:CC + | +LL | safe_raw(xraw, xshr); + | ^^^^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/aliasing_mut3.rs:LL:CC + | +LL | pub fn safe(_x: &mut i32, _y: &i32) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `safe` at $DIR/aliasing_mut3.rs:LL:CC +note: inside `main` at $DIR/aliasing_mut3.rs:LL:CC + --> $DIR/aliasing_mut3.rs:LL:CC + | +LL | safe_raw(xraw, xshr); + | ^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/aliasing_mut4.stderr b/tests/compile-fail/stacked_borrows/aliasing_mut4.stderr new file mode 100644 index 0000000000..13b589b947 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/aliasing_mut4.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + --> $DIR/aliasing_mut4.rs:LL:CC + | +LL | pub fn safe(_x: &i32, _y: &mut Cell) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/aliasing_mut4.rs:LL:CC + | +LL | let xref = &mut x; + | ^^^^^^ +help: was protected due to which was created here + --> $DIR/aliasing_mut4.rs:LL:CC + | +LL | safe_raw(xshr, xraw as *mut _); + | ^^^^ +help: this protector is live for this call + --> $DIR/aliasing_mut4.rs:LL:CC + | +LL | pub fn safe(_x: &i32, _y: &mut Cell) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `safe` at $DIR/aliasing_mut4.rs:LL:CC +note: inside `main` at $DIR/aliasing_mut4.rs:LL:CC + --> $DIR/aliasing_mut4.rs:LL:CC + | +LL | safe_raw(xshr, xraw as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/box_exclusive_violation1.stderr b/tests/compile-fail/stacked_borrows/box_exclusive_violation1.stderr new file mode 100644 index 0000000000..94d4509553 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/box_exclusive_violation1.stderr @@ -0,0 +1,38 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/box_exclusive_violation1.rs:LL:CC + | +LL | *our + | ^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/box_exclusive_violation1.rs:LL:CC + | +LL | / fn demo_mut_advanced_unique(mut our: Box) -> i32 { +LL | | unknown_code_1(&*our); +LL | | +LL | | // This "re-asserts" uniqueness of the reference: After writing, we know +... | +LL | | *our +LL | | } + | |_^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/box_exclusive_violation1.rs:LL:CC + | +LL | *LEAK = 7; + | ^^^^^^^^^ + = note: inside `demo_mut_advanced_unique` at $DIR/box_exclusive_violation1.rs:LL:CC +note: inside `main` at $DIR/box_exclusive_violation1.rs:LL:CC + --> $DIR/box_exclusive_violation1.rs:LL:CC + | +LL | demo_mut_advanced_unique(Box::new(0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/buggy_as_mut_slice.stderr b/tests/compile-fail/stacked_borrows/buggy_as_mut_slice.stderr new file mode 100644 index 0000000000..8eed3732a0 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/buggy_as_mut_slice.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/buggy_as_mut_slice.rs:LL:CC + | +LL | v1[1] = 5; + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0xc] + --> $DIR/buggy_as_mut_slice.rs:LL:CC + | +LL | let v1 = safe::as_mut_slice(&v); + | ^^^^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0xc] + --> $DIR/buggy_as_mut_slice.rs:LL:CC + | +LL | from_raw_parts_mut(self_.as_ptr() as *mut T, self_.len()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/buggy_as_mut_slice.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/buggy_split_at_mut.stderr b/tests/compile-fail/stacked_borrows/buggy_split_at_mut.stderr new file mode 100644 index 0000000000..d1d8d1f6aa --- /dev/null +++ b/tests/compile-fail/stacked_borrows/buggy_split_at_mut.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for Unique permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/buggy_split_at_mut.rs:LL:CC + | +LL | let (a, b) = safe::split_at_mut(&mut array, 0); + | ^ + | | + | trying to reborrow for Unique permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x10] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x10] + --> $DIR/buggy_split_at_mut.rs:LL:CC + | +LL | (from_raw_parts_mut(ptr, len - mid), // BUG: should be "mid" instead of "len - mid" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x10] + --> $DIR/buggy_split_at_mut.rs:LL:CC + | +LL | from_raw_parts_mut(ptr.offset(mid as isize), len - mid)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/buggy_split_at_mut.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/deallocate_against_barrier1.stderr b/tests/compile-fail/stacked_borrows/deallocate_against_barrier1.stderr new file mode 100644 index 0000000000..593419fe9b --- /dev/null +++ b/tests/compile-fail/stacked_borrows/deallocate_against_barrier1.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: deallocating while item is protected: [Unique for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC + = note: inside `::deallocate` at rustc_src/src/alloc.rs:LL:CC + = note: inside `alloc::alloc::box_free::` at rustc_src/src/alloc.rs:LL:CC + = note: inside `std::ptr::drop_in_place::> - shim(Some(std::boxed::Box))` at rustc_src/src/ptr/mod.rs:LL:CC + = note: inside `std::mem::drop::>` at rustc_src/src/mem/mod.rs:LL:CC +note: inside closure at $DIR/deallocate_against_barrier1.rs:LL:CC + --> $DIR/deallocate_against_barrier1.rs:LL:CC + | +LL | drop(unsafe { Box::from_raw(raw) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `<[closure@$DIR/deallocate_against_barrier1.rs:LL:CC: 12:6] as std::ops::FnOnce<(&mut i32,)>>::call_once - shim` at rustc_src/src/ops/function.rs:LL:CC +note: inside `inner` at $DIR/deallocate_against_barrier1.rs:LL:CC + --> $DIR/deallocate_against_barrier1.rs:LL:CC + | +LL | f(x) + | ^^^^ +note: inside `main` at $DIR/deallocate_against_barrier1.rs:LL:CC + --> $DIR/deallocate_against_barrier1.rs:LL:CC + | +LL | / inner(Box::leak(Box::new(0)), |x| { +LL | | let raw = x as *mut _; +LL | | drop(unsafe { Box::from_raw(raw) }); +LL | | }); + | |______^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/deallocate_against_barrier2.stderr b/tests/compile-fail/stacked_borrows/deallocate_against_barrier2.stderr new file mode 100644 index 0000000000..f6734db715 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/deallocate_against_barrier2.stderr @@ -0,0 +1,34 @@ +error: Undefined Behavior: deallocating while item is protected: [SharedReadWrite for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information + + = note: inside `std::alloc::dealloc` at rustc_src/src/alloc.rs:LL:CC + = note: inside `::deallocate` at rustc_src/src/alloc.rs:LL:CC + = note: inside `alloc::alloc::box_free::, std::alloc::Global>` at rustc_src/src/alloc.rs:LL:CC + = note: inside `std::ptr::drop_in_place::>> - shim(Some(std::boxed::Box>))` at rustc_src/src/ptr/mod.rs:LL:CC + = note: inside `std::mem::drop::>>` at rustc_src/src/mem/mod.rs:LL:CC +note: inside closure at $DIR/deallocate_against_barrier2.rs:LL:CC + --> $DIR/deallocate_against_barrier2.rs:LL:CC + | +LL | drop(unsafe { Box::from_raw(raw) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `<[closure@$DIR/deallocate_against_barrier2.rs:LL:CC: 16:6] as std::ops::FnOnce<(&std::cell::Cell,)>>::call_once - shim` at rustc_src/src/ops/function.rs:LL:CC +note: inside `inner` at $DIR/deallocate_against_barrier2.rs:LL:CC + --> $DIR/deallocate_against_barrier2.rs:LL:CC + | +LL | f(x) + | ^^^^ +note: inside `main` at $DIR/deallocate_against_barrier2.rs:LL:CC + --> $DIR/deallocate_against_barrier2.rs:LL:CC + | +LL | / inner(Box::leak(Box::new(Cell::new(0))), |x| { +LL | | let raw = x as *const _ as *mut Cell; +LL | | drop(unsafe { Box::from_raw(raw) }); +LL | | }); + | |______^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read1.stderr b/tests/compile-fail/stacked_borrows/illegal_read1.stderr new file mode 100644 index 0000000000..ca3147e622 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read1.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read1.rs:LL:CC + | +LL | let _val = *xref; // ...but any use of raw will invalidate our ref. + | ^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read1.rs:LL:CC + | +LL | let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok... + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read1.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; + | ^^^^^ + = note: inside `main` at $DIR/illegal_read1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read2.stderr b/tests/compile-fail/stacked_borrows/illegal_read2.stderr new file mode 100644 index 0000000000..b6343ddd30 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read2.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read2.rs:LL:CC + | +LL | let _val = *xref; // ...but any use of raw will invalidate our ref. + | ^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read2.rs:LL:CC + | +LL | let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok... + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read2.rs:LL:CC + | +LL | let shr = unsafe { &*xraw }; + | ^^^^^^ + = note: inside `main` at $DIR/illegal_read2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read3.stderr b/tests/compile-fail/stacked_borrows/illegal_read3.stderr new file mode 100644 index 0000000000..ab26696a76 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read3.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read3.rs:LL:CC + | +LL | let _val = *xref2; + | ^^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read3.rs:LL:CC + | +LL | let xref2 = &mut *xref1; + | ^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read3.rs:LL:CC + | +LL | let _val = unsafe { *xref1.to }; + | ^^^^^^^^^ + = note: inside `main` at $DIR/illegal_read3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read4.stderr b/tests/compile-fail/stacked_borrows/illegal_read4.stderr new file mode 100644 index 0000000000..968c31ba23 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read4.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read4.rs:LL:CC + | +LL | let _illegal = *xref2; + | ^^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read4.rs:LL:CC + | +LL | let xref2 = unsafe { &mut *xraw }; + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read4.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs + | ^^^^^ + = note: inside `main` at $DIR/illegal_read4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read5.rs b/tests/compile-fail/stacked_borrows/illegal_read5.rs index d6120cd64a..58f506251d 100644 --- a/tests/compile-fail/stacked_borrows/illegal_read5.rs +++ b/tests/compile-fail/stacked_borrows/illegal_read5.rs @@ -1,5 +1,6 @@ // We *can* have aliasing &RefCell and &mut T, but we cannot read through the former. // Else we couldn't optimize based on the assumption that `xref` below is truly unique. +// normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::cell::RefCell; use std::{mem, ptr}; diff --git a/tests/compile-fail/stacked_borrows/illegal_read5.stderr b/tests/compile-fail/stacked_borrows/illegal_read5.stderr new file mode 100644 index 0000000000..df6f0a1c68 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read5.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[$HEX], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read5.rs:LL:CC + | +LL | let _val = *xref; // the mutable one is dead and gone + | ^^^^^ + | | + | attempting a read access using at ALLOC[$HEX], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[$HEX..$HEX] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [$HEX..$HEX] + --> $DIR/illegal_read5.rs:LL:CC + | +LL | let xref: &mut i32 = &mut *refmut; + | ^^^^^^^^^^^^ +help: was later invalidated at offsets [$HEX..$HEX] + --> $DIR/illegal_read5.rs:LL:CC + | +LL | mem::forget(unsafe { ptr::read(xshr) }); // but after reading through the shared ref + | ^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/illegal_read5.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read6.stderr b/tests/compile-fail/stacked_borrows/illegal_read6.stderr new file mode 100644 index 0000000000..c2be5bb370 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read6.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read6.rs:LL:CC + | +LL | let _val = *raw; + | ^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/illegal_read6.rs:LL:CC + | +LL | let raw = x as *mut _; + | ^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read6.rs:LL:CC + | +LL | let x = &mut *x; // kill `raw` + | ^^^^^^^ + = note: inside `main` at $DIR/illegal_read6.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read7.stderr b/tests/compile-fail/stacked_borrows/illegal_read7.stderr new file mode 100644 index 0000000000..921d8872b7 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read7.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read7.rs:LL:CC + | +LL | let _val = *x.get_mut(); + | ^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read7.rs:LL:CC + | +LL | let x = &mut *raw; + | ^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read7.rs:LL:CC + | +LL | let _val = ptr::read(raw); + | ^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/illegal_read7.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_read8.stderr b/tests/compile-fail/stacked_borrows/illegal_read8.stderr new file mode 100644 index 0000000000..6c6168032b --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_read8.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_read8.rs:LL:CC + | +LL | let _fail = *y1; + | ^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_read8.rs:LL:CC + | +LL | let y1: &i32 = mem::transmute(&*x); // launder lifetimes + | ^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_read8.rs:LL:CC + | +LL | *y2 += 1; + | ^^^^^^^^ + = note: inside `main` at $DIR/illegal_read8.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write1.stderr b/tests/compile-fail/stacked_borrows/illegal_write1.stderr new file mode 100644 index 0000000000..08fa05ff9f --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write1.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_write1.rs:LL:CC + | +LL | let _x = *xref; + | ^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_write1.rs:LL:CC + | +LL | let xref = &*target; + | ^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_write1.rs:LL:CC + | +LL | unsafe { *x = 42; } // invalidates shared ref, activates raw + | ^^^^^^^ + = note: inside `main` at $DIR/illegal_write1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write2.stderr b/tests/compile-fail/stacked_borrows/illegal_write2.stderr new file mode 100644 index 0000000000..13f41eea91 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write2.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_write2.rs:LL:CC + | +LL | unsafe { *target2 = 13; } + | ^^^^^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/illegal_write2.rs:LL:CC + | +LL | let target2 = target as *mut _; + | ^^^^^^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_write2.rs:LL:CC + | +LL | drop(&mut *target); // reborrow + | ^^^^^^^^^^^^ + = note: inside `main` at $DIR/illegal_write2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write3.stderr b/tests/compile-fail/stacked_borrows/illegal_write3.stderr new file mode 100644 index 0000000000..b37caee5ef --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write3.stderr @@ -0,0 +1,22 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location + --> $DIR/illegal_write3.rs:LL:CC + | +LL | unsafe { *ptr = 42; } + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/illegal_write3.rs:LL:CC + | +LL | let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag + | ^^^^^ + = note: inside `main` at $DIR/illegal_write3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write4.stderr b/tests/compile-fail/stacked_borrows/illegal_write4.stderr new file mode 100644 index 0000000000..5c0b4ec868 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write4.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_write4.rs:LL:CC + | +LL | let _val = *reference; + | ^^^^^^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_write4.rs:LL:CC + | +LL | let reference = unsafe { &*raw }; // freeze + | ^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_write4.rs:LL:CC + | +LL | let _mut_ref: &mut i32 = unsafe { mem::transmute(ptr) }; // &mut, with raw tag + | ^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/illegal_write4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write5.stderr b/tests/compile-fail/stacked_borrows/illegal_write5.stderr new file mode 100644 index 0000000000..f9a4dcfd8d --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write5.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/illegal_write5.rs:LL:CC + | +LL | let _val = *xref; + | ^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/illegal_write5.rs:LL:CC + | +LL | let xref = unsafe { &mut *xraw }; + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/illegal_write5.rs:LL:CC + | +LL | unsafe { *xraw = 15 }; + | ^^^^^^^^^^ + = note: inside `main` at $DIR/illegal_write5.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/illegal_write6.stderr b/tests/compile-fail/stacked_borrows/illegal_write6.stderr new file mode 100644 index 0000000000..5861aeefaf --- /dev/null +++ b/tests/compile-fail/stacked_borrows/illegal_write6.stderr @@ -0,0 +1,39 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [Unique for (call ID)] + --> $DIR/illegal_write6.rs:LL:CC + | +LL | unsafe { *y = 2; } + | ^^^^^^ not granting access to tag because incompatible item is protected: [Unique for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/illegal_write6.rs:LL:CC + | +LL | let p = x as *mut u32; + | ^ +help: was protected due to a tag which was created here + --> $DIR/illegal_write6.rs:LL:CC + | +LL | foo(x, p); + | ^ +help: this protector is live for this call + --> $DIR/illegal_write6.rs:LL:CC + | +LL | / fn foo(a: &mut u32, y: *mut u32) -> u32 { +LL | | *a = 1; +LL | | let _b = &*a; +LL | | unsafe { *y = 2; } +LL | | return *a; +LL | | } + | |_^ + = note: inside `foo` at $DIR/illegal_write6.rs:LL:CC +note: inside `main` at $DIR/illegal_write6.rs:LL:CC + --> $DIR/illegal_write6.rs:LL:CC + | +LL | foo(x, p); + | ^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/interior_mut1.stderr b/tests/compile-fail/stacked_borrows/interior_mut1.stderr new file mode 100644 index 0000000000..af4163c936 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/interior_mut1.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/interior_mut1.rs:LL:CC + | +LL | let _val = *inner_shr.get(); + | ^^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/interior_mut1.rs:LL:CC + | +LL | let inner_shr = &*inner_uniq; // adds a SharedReadWrite + | ^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/interior_mut1.rs:LL:CC + | +LL | *c.get() = UnsafeCell::new(1); // invalidates inner_shr + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/interior_mut1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/interior_mut2.stderr b/tests/compile-fail/stacked_borrows/interior_mut2.stderr new file mode 100644 index 0000000000..5a4ddf381e --- /dev/null +++ b/tests/compile-fail/stacked_borrows/interior_mut2.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/interior_mut2.rs:LL:CC + | +LL | let _val = *inner_shr.get(); + | ^^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/interior_mut2.rs:LL:CC + | +LL | let inner_shr = &*inner_uniq; + | ^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/interior_mut2.rs:LL:CC + | +LL | *c.get() = UnsafeCell::new(0); // now inner_shr gets invalidated + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/interior_mut2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/invalidate_against_barrier1.stderr b/tests/compile-fail/stacked_borrows/invalidate_against_barrier1.stderr new file mode 100644 index 0000000000..47f7a06a85 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/invalidate_against_barrier1.stderr @@ -0,0 +1,39 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [Unique for (call ID)] + --> $DIR/invalidate_against_barrier1.rs:LL:CC + | +LL | let _val = unsafe { *x }; + | ^^ not granting access to tag because incompatible item is protected: [Unique for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/invalidate_against_barrier1.rs:LL:CC + | +LL | let xraw = &mut x as *mut _; + | ^^^^^^ +help: was protected due to a tag which was created here + --> $DIR/invalidate_against_barrier1.rs:LL:CC + | +LL | inner(xraw, xref); + | ^^^^ +help: this protector is live for this call + --> $DIR/invalidate_against_barrier1.rs:LL:CC + | +LL | / fn inner(x: *mut i32, _y: &mut i32) { +LL | | // If `x` and `y` alias, retagging is fine with this... but we really +LL | | // shouldn't be allowed to use `x` at all because `y` was assumed to be +LL | | // unique for the duration of this call. +LL | | let _val = unsafe { *x }; +LL | | } + | |_^ + = note: inside `inner` at $DIR/invalidate_against_barrier1.rs:LL:CC +note: inside `main` at $DIR/invalidate_against_barrier1.rs:LL:CC + --> $DIR/invalidate_against_barrier1.rs:LL:CC + | +LL | inner(xraw, xref); + | ^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/invalidate_against_barrier2.stderr b/tests/compile-fail/stacked_borrows/invalidate_against_barrier2.stderr new file mode 100644 index 0000000000..fa2e6aa05a --- /dev/null +++ b/tests/compile-fail/stacked_borrows/invalidate_against_barrier2.stderr @@ -0,0 +1,39 @@ +error: Undefined Behavior: not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + --> $DIR/invalidate_against_barrier2.rs:LL:CC + | +LL | unsafe { *x = 0 }; + | ^^^^^^ not granting access to tag because incompatible item is protected: [SharedReadOnly for (call ID)] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/invalidate_against_barrier2.rs:LL:CC + | +LL | let xraw = &mut x as *mut _; + | ^^^^^^ +help: was protected due to a tag which was created here + --> $DIR/invalidate_against_barrier2.rs:LL:CC + | +LL | inner(xraw, xref); + | ^^^^ +help: this protector is live for this call + --> $DIR/invalidate_against_barrier2.rs:LL:CC + | +LL | / fn inner(x: *mut i32, _y: &i32) { +LL | | // If `x` and `y` alias, retagging is fine with this... but we really +LL | | // shouldn't be allowed to write to `x` at all because `y` was assumed to be +LL | | // immutable for the duration of this call. +LL | | unsafe { *x = 0 }; +LL | | } + | |_^ + = note: inside `inner` at $DIR/invalidate_against_barrier2.rs:LL:CC +note: inside `main` at $DIR/invalidate_against_barrier2.rs:LL:CC + --> $DIR/invalidate_against_barrier2.rs:LL:CC + | +LL | inner(xraw, xref); + | ^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/issue-miri-1050-1.stderr b/tests/compile-fail/stacked_borrows/issue-miri-1050-1.stderr new file mode 100644 index 0000000000..70c774818b --- /dev/null +++ b/tests/compile-fail/stacked_borrows/issue-miri-1050-1.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: ALLOC has size 2, so pointer to 4 bytes starting at offset 0 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::boxed::Box::::from_raw_in` at rustc_src/src/boxed.rs:LL:CC + = note: inside `std::boxed::Box::::from_raw` at rustc_src/src/boxed.rs:LL:CC +note: inside `main` at $DIR/issue-miri-1050-1.rs:LL:CC + --> $DIR/issue-miri-1050-1.rs:LL:CC + | +LL | Box::from_raw(ptr as *mut u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/issue-miri-1050-2.rs b/tests/compile-fail/stacked_borrows/issue-miri-1050-2.rs index 30cbf0b339..8f0b475016 100644 --- a/tests/compile-fail/stacked_borrows/issue-miri-1050-2.rs +++ b/tests/compile-fail/stacked_borrows/issue-miri-1050-2.rs @@ -1,4 +1,4 @@ -// error-pattern: 0x4 is not a valid pointer +// error-pattern: is not a valid pointer use std::ptr::NonNull; fn main() { unsafe { diff --git a/tests/compile-fail/stacked_borrows/issue-miri-1050-2.stderr b/tests/compile-fail/stacked_borrows/issue-miri-1050-2.stderr new file mode 100644 index 0000000000..579f728b2b --- /dev/null +++ b/tests/compile-fail/stacked_borrows/issue-miri-1050-2.stderr @@ -0,0 +1,17 @@ +error: Undefined Behavior: 0x4 is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::boxed::Box::::from_raw_in` at rustc_src/src/boxed.rs:LL:CC + = note: inside `std::boxed::Box::::from_raw` at rustc_src/src/boxed.rs:LL:CC +note: inside `main` at $DIR/issue-miri-1050-2.rs:LL:CC + --> $DIR/issue-miri-1050-2.rs:LL:CC + | +LL | Box::from_raw(ptr.as_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/load_invalid_mut.stderr b/tests/compile-fail/stacked_borrows/load_invalid_mut.stderr new file mode 100644 index 0000000000..00eda4fe5a --- /dev/null +++ b/tests/compile-fail/stacked_borrows/load_invalid_mut.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for Unique permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/load_invalid_mut.rs:LL:CC + | +LL | let _val = *xref_in_mem; + | ^^^^^^^^^^^^ + | | + | trying to reborrow for Unique permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/load_invalid_mut.rs:LL:CC + | +LL | let xref_in_mem = Box::new(xref); + | ^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/load_invalid_mut.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // invalidate xref + | ^^^^^ + = note: inside `main` at $DIR/load_invalid_mut.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/load_invalid_shr.stderr b/tests/compile-fail/stacked_borrows/load_invalid_shr.stderr new file mode 100644 index 0000000000..eb61b4762f --- /dev/null +++ b/tests/compile-fail/stacked_borrows/load_invalid_shr.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/load_invalid_shr.rs:LL:CC + | +LL | let _val = *xref_in_mem; + | ^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/load_invalid_shr.rs:LL:CC + | +LL | let xref_in_mem = Box::new(xref); + | ^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/load_invalid_shr.rs:LL:CC + | +LL | unsafe { *xraw = 42 }; // unfreeze + | ^^^^^^^^^^ + = note: inside `main` at $DIR/load_invalid_shr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/mut_exclusive_violation1.stderr b/tests/compile-fail/stacked_borrows/mut_exclusive_violation1.stderr new file mode 100644 index 0000000000..2d8ef7c1a4 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/mut_exclusive_violation1.stderr @@ -0,0 +1,37 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/mut_exclusive_violation1.rs:LL:CC + | +LL | *LEAK = 7; + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/mut_exclusive_violation1.rs:LL:CC + | +LL | LEAK = x as *const _ as *mut _; + | ^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/mut_exclusive_violation1.rs:LL:CC + | +LL | *our = 5; + | ^^^^^^^^ + = note: inside `unknown_code_2` at $DIR/mut_exclusive_violation1.rs:LL:CC +note: inside `demo_mut_advanced_unique` at $DIR/mut_exclusive_violation1.rs:LL:CC + --> $DIR/mut_exclusive_violation1.rs:LL:CC + | +LL | unknown_code_2(); + | ^^^^^^^^^^^^^^^^ +note: inside `main` at $DIR/mut_exclusive_violation1.rs:LL:CC + --> $DIR/mut_exclusive_violation1.rs:LL:CC + | +LL | demo_mut_advanced_unique(&mut 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/mut_exclusive_violation2.stderr b/tests/compile-fail/stacked_borrows/mut_exclusive_violation2.stderr new file mode 100644 index 0000000000..ae0eab467b --- /dev/null +++ b/tests/compile-fail/stacked_borrows/mut_exclusive_violation2.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/mut_exclusive_violation2.rs:LL:CC + | +LL | let _val = *raw1; + | ^^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/mut_exclusive_violation2.rs:LL:CC + | +LL | let raw1 = ptr1.as_mut(); + | ^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/mut_exclusive_violation2.rs:LL:CC + | +LL | let _raw2 = ptr2.as_mut(); + | ^^^^^^^^^^^^^ + = note: inside `main` at $DIR/mut_exclusive_violation2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/outdated_local.stderr b/tests/compile-fail/stacked_borrows/outdated_local.stderr new file mode 100644 index 0000000000..1c1deac231 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/outdated_local.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/outdated_local.rs:LL:CC + | +LL | assert_eq!(unsafe { *y }, 1); + | ^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/outdated_local.rs:LL:CC + | +LL | let y: *const i32 = &x; + | ^^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/outdated_local.rs:LL:CC + | +LL | x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local + | ^^^^^ + = note: inside `main` at $DIR/outdated_local.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/pass_invalid_mut.stderr b/tests/compile-fail/stacked_borrows/pass_invalid_mut.stderr new file mode 100644 index 0000000000..280e51693a --- /dev/null +++ b/tests/compile-fail/stacked_borrows/pass_invalid_mut.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/pass_invalid_mut.rs:LL:CC + | +LL | foo(xref); + | ^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/pass_invalid_mut.rs:LL:CC + | +LL | let xref = unsafe { &mut *xraw }; + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/pass_invalid_mut.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // invalidate xref + | ^^^^^ + = note: inside `main` at $DIR/pass_invalid_mut.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/pass_invalid_shr.stderr b/tests/compile-fail/stacked_borrows/pass_invalid_shr.stderr new file mode 100644 index 0000000000..b111832193 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/pass_invalid_shr.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/pass_invalid_shr.rs:LL:CC + | +LL | foo(xref); + | ^^^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/pass_invalid_shr.rs:LL:CC + | +LL | let xref = unsafe { &*xraw }; + | ^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/pass_invalid_shr.rs:LL:CC + | +LL | unsafe { *xraw = 42 }; // unfreeze + | ^^^^^^^^^^ + = note: inside `main` at $DIR/pass_invalid_shr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/pointer_smuggling.stderr b/tests/compile-fail/stacked_borrows/pointer_smuggling.stderr new file mode 100644 index 0000000000..097de439f7 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/pointer_smuggling.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/pointer_smuggling.rs:LL:CC + | +LL | let _x = unsafe { *PTR }; + | ^^^^ + | | + | attempting a read access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x1] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x1] + --> $DIR/pointer_smuggling.rs:LL:CC + | +LL | PTR = x; + | ^ +help: tag was later invalidated at offsets [0x0..0x1] + --> $DIR/pointer_smuggling.rs:LL:CC + | +LL | *val = 2; // this invalidates any raw ptrs `fun1` might have created. + | ^^^^^^^^ + = note: inside `fun2` at $DIR/pointer_smuggling.rs:LL:CC +note: inside `main` at $DIR/pointer_smuggling.rs:LL:CC + --> $DIR/pointer_smuggling.rs:LL:CC + | +LL | fun2(); // if they now use a raw ptr they break our reference + | ^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/raw_tracking.stderr b/tests/compile-fail/stacked_borrows/raw_tracking.stderr new file mode 100644 index 0000000000..a03d55a904 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/raw_tracking.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/raw_tracking.rs:LL:CC + | +LL | unsafe { *raw1 = 13; } + | ^^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/raw_tracking.rs:LL:CC + | +LL | let raw1 = &mut l as *mut _; + | ^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/raw_tracking.rs:LL:CC + | +LL | let raw2 = &mut l as *mut _; // invalidates raw1 + | ^^^^^^ + = note: inside `main` at $DIR/raw_tracking.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_mut.stderr b/tests/compile-fail/stacked_borrows/return_invalid_mut.stderr new file mode 100644 index 0000000000..6de657b829 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_mut.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_mut.rs:LL:CC + | +LL | ret + | ^^^ + | | + | trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_mut.rs:LL:CC + | +LL | let ret = unsafe { &mut (*xraw).1 }; + | ^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_mut.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // invalidate xref + | ^^^^^ + = note: inside `foo` at $DIR/return_invalid_mut.rs:LL:CC +note: inside `main` at $DIR/return_invalid_mut.rs:LL:CC + --> $DIR/return_invalid_mut.rs:LL:CC + | +LL | foo(&mut (1, 2)); + | ^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_mut_option.stderr b/tests/compile-fail/stacked_borrows/return_invalid_mut_option.stderr new file mode 100644 index 0000000000..8b95765dcc --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_mut_option.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_mut_option.rs:LL:CC + | +LL | Some(_x) => {}, + | ^^ + | | + | trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_mut_option.rs:LL:CC + | +LL | let ret = Some(ret); + | ^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_mut_option.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // invalidate xref + | ^^^^^ + = note: inside `main` at $DIR/return_invalid_mut_option.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_mut_tuple.stderr b/tests/compile-fail/stacked_borrows/return_invalid_mut_tuple.stderr new file mode 100644 index 0000000000..f9e6d65c78 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_mut_tuple.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_mut_tuple.rs:LL:CC + | +LL | foo(&mut (1, 2)).0; + | ^^^^^^^^^^^^^^^^^^ + | | + | trying to reborrow for Unique permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_mut_tuple.rs:LL:CC + | +LL | let ret = (unsafe { &mut (*xraw).1 },); + | ^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_mut_tuple.rs:LL:CC + | +LL | let _val = unsafe { *xraw }; // invalidate xref + | ^^^^^ + = note: inside `main` at $DIR/return_invalid_mut_tuple.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_shr.stderr b/tests/compile-fail/stacked_borrows/return_invalid_shr.stderr new file mode 100644 index 0000000000..20dcb8e93c --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_shr.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_shr.rs:LL:CC + | +LL | ret + | ^^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_shr.rs:LL:CC + | +LL | let ret = unsafe { &(*xraw).1 }; + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_shr.rs:LL:CC + | +LL | unsafe { *xraw = (42, 23) }; // unfreeze + | ^^^^^^^^^^^^^^^^ + = note: inside `foo` at $DIR/return_invalid_shr.rs:LL:CC +note: inside `main` at $DIR/return_invalid_shr.rs:LL:CC + --> $DIR/return_invalid_shr.rs:LL:CC + | +LL | foo(&mut (1, 2)); + | ^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_shr_option.stderr b/tests/compile-fail/stacked_borrows/return_invalid_shr_option.stderr new file mode 100644 index 0000000000..0c41a10a3f --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_shr_option.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_shr_option.rs:LL:CC + | +LL | Some(_x) => {}, + | ^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_shr_option.rs:LL:CC + | +LL | let ret = Some(unsafe { &(*xraw).1 }); + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_shr_option.rs:LL:CC + | +LL | unsafe { *xraw = (42, 23) }; // unfreeze + | ^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/return_invalid_shr_option.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/return_invalid_shr_tuple.stderr b/tests/compile-fail/stacked_borrows/return_invalid_shr_tuple.stderr new file mode 100644 index 0000000000..9e7be7ad01 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/return_invalid_shr_tuple.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + --> $DIR/return_invalid_shr_tuple.rs:LL:CC + | +LL | foo(&mut (1, 2)).0; + | ^^^^^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x4..0x8] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x4..0x8] + --> $DIR/return_invalid_shr_tuple.rs:LL:CC + | +LL | let ret = (unsafe { &(*xraw).1 },); + | ^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x8] + --> $DIR/return_invalid_shr_tuple.rs:LL:CC + | +LL | unsafe { *xraw = (42, 23) }; // unfreeze + | ^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/return_invalid_shr_tuple.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak1.stderr b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak1.stderr new file mode 100644 index 0000000000..576a21bbf6 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak1.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC + | +LL | y.get_mut(); + | ^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [0x0..0x4] + --> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC + | +LL | let y: &mut Cell = mem::transmute(&mut *x); // launder lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [0x0..0x4] + --> $DIR/shared_rw_borrows_are_weak1.rs:LL:CC + | +LL | shr_rw.set(1); + | ^^^^^^^^^^^^^ + = note: inside `main` at $DIR/shared_rw_borrows_are_weak1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.rs b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.rs index 942bb503db..d4aef74dff 100644 --- a/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.rs +++ b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.rs @@ -1,6 +1,7 @@ // We want to test that granting a SharedReadWrite will be added // *below* an already granted SharedReadWrite -- so writing to // the SharedReadWrite will invalidate the SharedReadWrite. +// normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::mem; use std::cell::RefCell; diff --git a/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.stderr b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.stderr new file mode 100644 index 0000000000..e2159ed589 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/shared_rw_borrows_are_weak2.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[$HEX], but that tag does not exist in the borrow stack for this location + --> $DIR/shared_rw_borrows_are_weak2.rs:LL:CC + | +LL | let _val = *y; + | ^^ + | | + | attempting a read access using at ALLOC[$HEX], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[$HEX..$HEX] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: was created by a retag at offsets [$HEX..$HEX] + --> $DIR/shared_rw_borrows_are_weak2.rs:LL:CC + | +LL | let y: &i32 = mem::transmute(&*x.borrow()); // launder lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: was later invalidated at offsets [$HEX..$HEX] + --> $DIR/shared_rw_borrows_are_weak2.rs:LL:CC + | +LL | shr_rw.replace(1); + | ^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/shared_rw_borrows_are_weak2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/shr_frozen_violation1.stderr b/tests/compile-fail/stacked_borrows/shr_frozen_violation1.stderr new file mode 100644 index 0000000000..689ad1c6b6 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/shr_frozen_violation1.stderr @@ -0,0 +1,32 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location + --> $DIR/shr_frozen_violation1.rs:LL:CC + | +LL | unsafe { *(x as *const i32 as *mut i32) = 7; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/shr_frozen_violation1.rs:LL:CC + | +LL | unsafe { *(x as *const i32 as *mut i32) = 7; } + | ^ + = note: inside `unknown_code` at $DIR/shr_frozen_violation1.rs:LL:CC +note: inside `foo` at $DIR/shr_frozen_violation1.rs:LL:CC + --> $DIR/shr_frozen_violation1.rs:LL:CC + | +LL | unknown_code(&*x); + | ^^^^^^^^^^^^^^^^^ +note: inside `main` at $DIR/shr_frozen_violation1.rs:LL:CC + --> $DIR/shr_frozen_violation1.rs:LL:CC + | +LL | println!("{}", foo(&mut 0)); + | ^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/static_memory_modification.rs b/tests/compile-fail/stacked_borrows/static_memory_modification.rs index 417a03bb03..72e2ed9381 100644 --- a/tests/compile-fail/stacked_borrows/static_memory_modification.rs +++ b/tests/compile-fail/stacked_borrows/static_memory_modification.rs @@ -3,6 +3,6 @@ static X: usize = 5; #[allow(mutable_transmutes)] fn main() { let _x = unsafe { - std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to alloc1 which is read-only + std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR writing to ALLOC which is read-only }; } diff --git a/tests/compile-fail/stacked_borrows/static_memory_modification.stderr b/tests/compile-fail/stacked_borrows/static_memory_modification.stderr new file mode 100644 index 0000000000..091eb29f64 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/static_memory_modification.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/static_memory_modification.rs:LL:CC + | +LL | std::mem::transmute::<&usize, &mut usize>(&X) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/static_memory_modification.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/transmute-is-no-escape.stderr b/tests/compile-fail/stacked_borrows/transmute-is-no-escape.stderr new file mode 100644 index 0000000000..f2ea4f919c --- /dev/null +++ b/tests/compile-fail/stacked_borrows/transmute-is-no-escape.stderr @@ -0,0 +1,18 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/transmute-is-no-escape.rs:LL:CC + | +LL | unsafe { *raw = 13; } + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information + + = note: inside `main` at $DIR/transmute-is-no-escape.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/unescaped_local.stderr b/tests/compile-fail/stacked_borrows/unescaped_local.stderr new file mode 100644 index 0000000000..a8d869549a --- /dev/null +++ b/tests/compile-fail/stacked_borrows/unescaped_local.stderr @@ -0,0 +1,27 @@ +error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + --> $DIR/unescaped_local.rs:LL:CC + | +LL | unsafe { *raw = 13; } + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information +help: tag was most recently created at offsets [0x0..0x4] + --> $DIR/unescaped_local.rs:LL:CC + | +LL | let raw = &mut x as *mut i32 as usize as *mut i32; + | ^^^^^^ +help: tag was later invalidated at offsets [0x0..0x4] + --> $DIR/unescaped_local.rs:LL:CC + | +LL | let _ptr = &mut x; + | ^^^^^^ + = note: inside `main` at $DIR/unescaped_local.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/unescaped_static.stderr b/tests/compile-fail/stacked_borrows/unescaped_static.stderr new file mode 100644 index 0000000000..b191855644 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/unescaped_static.stderr @@ -0,0 +1,18 @@ +error: Undefined Behavior: attempting a read access using at ALLOC[0x1], but that tag does not exist in the borrow stack for this location + --> $DIR/unescaped_static.rs:LL:CC + | +LL | let _val = unsafe { *ptr_to_first.add(1) }; + | ^^^^^^^^^^^^^^^^^^^^ + | | + | attempting a read access using at ALLOC[0x1], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x1..0x2] + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information + + = note: inside `main` at $DIR/unescaped_static.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/stacked_borrows/zst_slice.stderr b/tests/compile-fail/stacked_borrows/zst_slice.stderr new file mode 100644 index 0000000000..f9d8b024e9 --- /dev/null +++ b/tests/compile-fail/stacked_borrows/zst_slice.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: trying to reborrow for SharedReadOnly permission at ALLOC[0x4], but that tag does not exist in the borrow stack for this location + | + = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental + = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information + + = note: inside `core::slice::::get_unchecked::` at rustc_src/src/slice/mod.rs:LL:CC +note: inside `main` at $DIR/zst_slice.rs:LL:CC + --> $DIR/zst_slice.rs:LL:CC + | +LL | assert_eq!(*s.get_unchecked(1), 2); + | ^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/static_memory_modification1.stderr b/tests/compile-fail/static_memory_modification1.stderr new file mode 100644 index 0000000000..a37a79fa56 --- /dev/null +++ b/tests/compile-fail/static_memory_modification1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/static_memory_modification1.rs:LL:CC + | +LL | *std::mem::transmute::<&usize, &mut usize>(&X) = 6; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/static_memory_modification1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/static_memory_modification2.stderr b/tests/compile-fail/static_memory_modification2.stderr new file mode 100644 index 0000000000..d38f3f6342 --- /dev/null +++ b/tests/compile-fail/static_memory_modification2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/static_memory_modification2.rs:LL:CC + | +LL | transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/static_memory_modification2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/static_memory_modification3.stderr b/tests/compile-fail/static_memory_modification3.stderr new file mode 100644 index 0000000000..96e3877c54 --- /dev/null +++ b/tests/compile-fail/static_memory_modification3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/static_memory_modification3.rs:LL:CC + | +LL | transmute::<&[u8], &mut [u8]>(bs)[4] = 42; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC which is read-only + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/static_memory_modification3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/strict-provenance-offset.stderr b/tests/compile-fail/strict-provenance-offset.stderr new file mode 100644 index 0000000000..482b7a404c --- /dev/null +++ b/tests/compile-fail/strict-provenance-offset.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: pointer arithmetic failed: $HEX is not a valid pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::ptr::const_ptr::::offset` at rustc_src/src/ptr/const_ptr.rs:LL:CC +note: inside `main` at $DIR/strict-provenance-offset.rs:LL:CC + --> $DIR/strict-provenance-offset.rs:LL:CC + | +LL | let _ = unsafe { roundtrip.offset(1) }; + | ^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/strict_provenance_transmute.stderr b/tests/compile-fail/strict_provenance_transmute.stderr new file mode 100644 index 0000000000..c2140b9786 --- /dev/null +++ b/tests/compile-fail/strict_provenance_transmute.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: type validation failed: encountered pointer to $HEX[ALLOC], but expected initialized plain (non-pointer) bytes + --> $DIR/strict_provenance_transmute.rs:LL:CC + | +LL | let left_int: usize = mem::transmute(left); + | ^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to $HEX[ALLOC], but expected initialized plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `deref` at $DIR/strict_provenance_transmute.rs:LL:CC +note: inside `main` at $DIR/strict_provenance_transmute.rs:LL:CC + --> $DIR/strict_provenance_transmute.rs:LL:CC + | +LL | deref(ptr1, ptr2.with_addr(ptr1.addr())); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_cond_double_destroy.stderr b/tests/compile-fail/sync/libc_pthread_cond_double_destroy.stderr new file mode 100644 index 0000000000..3629526781 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_cond_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_cond_double_destroy.rs:LL:CC + | +LL | libc::pthread_cond_destroy(cond.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_cond_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_condattr_double_destroy.stderr b/tests/compile-fail/sync/libc_pthread_condattr_double_destroy.stderr new file mode 100644 index 0000000000..14439445e7 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_condattr_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC + | +LL | libc::pthread_condattr_destroy(attr.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_condattr_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_NULL_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_mutex_NULL_deadlock.stderr new file mode 100644 index 0000000000..d42174b9fb --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_NULL_deadlock.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to acquire already locked default mutex + --> $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutex_NULL_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_mutex_deadlock.stderr new file mode 100644 index 0000000000..ac37096ad8 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_deadlock.stderr @@ -0,0 +1,14 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_mutex_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_mutex_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_default_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_mutex_default_deadlock.stderr new file mode 100644 index 0000000000..cb5daef68c --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_default_deadlock.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to acquire already locked default mutex + --> $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to acquire already locked default mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutex_default_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.stderr b/tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.stderr new file mode 100644 index 0000000000..96a3c645ab --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked mutex + --> $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC + | +LL | libc::pthread_mutex_destroy(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked mutex + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutex_destroy_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_double_destroy.stderr b/tests/compile-fail/sync/libc_pthread_mutex_double_destroy.stderr new file mode 100644 index 0000000000..9df2dd32b8 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC + | +LL | libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutex_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.stderr new file mode 100644 index 0000000000..b7877d3aa3 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC + | +LL | libc::pthread_mutex_lock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr b/tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr new file mode 100644 index 0000000000..b0858374cd --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread + --> $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC + | +LL | libc::pthread_mutex_unlock(&mut mutex as *mut _); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a PTHREAD_MUTEX_NORMAL mutex that was not locked by the current thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutex_normal_unlock_unlocked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_mutex_wrong_owner.stderr b/tests/compile-fail/sync/libc_pthread_mutex_wrong_owner.stderr new file mode 100644 index 0000000000..6603b264d9 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutex_wrong_owner.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: unlocked a default mutex that was not locked by the current thread + --> $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC + | +LL | ...t_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked a default mutex that was not locked by the current thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/sync/libc_pthread_mutexattr_double_destroy.stderr b/tests/compile-fail/sync/libc_pthread_mutexattr_double_destroy.stderr new file mode 100644 index 0000000000..21adfa61d1 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_mutexattr_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC + | +LL | libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_mutexattr_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.stderr new file mode 100644 index 0000000000..80a88a773e --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked rwlock + --> $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_read_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.stderr new file mode 100644 index 0000000000..0fd49a6330 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: destroyed a locked rwlock + --> $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ destroyed a locked rwlock + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_rwlock_destroy_write_locked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_double_destroy.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_double_destroy.stderr new file mode 100644 index 0000000000..d60afc67c8 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_double_destroy.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC + | +LL | libc::pthread_rwlock_destroy(&mut lock); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_rwlock_double_destroy.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr new file mode 100644 index 0000000000..075c8f0ef5 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_wrlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_read_wrong_owner.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_read_wrong_owner.stderr new file mode 100644 index 0000000000..d3820f0dcb --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_read_wrong_owner.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.stderr new file mode 100644 index 0000000000..f8454d0558 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC + | +LL | libc::pthread_rwlock_unlock(rw.get()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/libc_pthread_rwlock_unlock_unlocked.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.stderr new file mode 100644 index 0000000000..748a363a27 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.stderr @@ -0,0 +1,14 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr new file mode 100644 index 0000000000..caab19a782 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_rdlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.stderr new file mode 100644 index 0000000000..c6a03ff9af --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.stderr @@ -0,0 +1,14 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC + | +LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); + | ^ the evaluated program deadlocked + | + = note: inside closure at $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr new file mode 100644 index 0000000000..30f5f447c7 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr @@ -0,0 +1,12 @@ +error: deadlock: the evaluated program deadlocked + --> $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC + | +LL | libc::pthread_rwlock_wrlock(rw.get()); + | ^ the evaluated program deadlocked + | + = note: inside `main` at $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_wrong_owner.stderr b/tests/compile-fail/sync/libc_pthread_rwlock_write_wrong_owner.stderr new file mode 100644 index 0000000000..02a6cf11c0 --- /dev/null +++ b/tests/compile-fail/sync/libc_pthread_rwlock_write_wrong_owner.stderr @@ -0,0 +1,17 @@ +warning: thread support is experimental and incomplete: weak memory effects are not emulated. + +error: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + --> $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC + | +LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unlocked an rwlock that was not locked by the active thread + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside closure at $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/compile-fail/too-big-slice.stderr b/tests/compile-fail/too-big-slice.stderr new file mode 100644 index 0000000000..11d20d3e62 --- /dev/null +++ b/tests/compile-fail/too-big-slice.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/too-big-slice.rs:LL:CC + | +LL | let _x: &[u8] = mem::transmute((ptr, usize::MAX)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/too-big-slice.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/too-big-unsized.stderr b/tests/compile-fail/too-big-unsized.stderr new file mode 100644 index 0000000000..0c7b7b2324 --- /dev/null +++ b/tests/compile-fail/too-big-unsized.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered invalid reference metadata: total size is bigger than largest supported object + --> $DIR/too-big-unsized.rs:LL:CC + | +LL | let _x: &MySlice = mem::transmute((ptr, isize::MAX as usize)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: total size is bigger than largest supported object + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/too-big-unsized.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/transmute-pair-uninit.stderr b/tests/compile-fail/transmute-pair-uninit.stderr new file mode 100644 index 0000000000..f574e97402 --- /dev/null +++ b/tests/compile-fail/transmute-pair-uninit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/transmute-pair-uninit.rs:LL:CC + | +LL | if v == 0 { println!("it is zero"); } + | ^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/transmute-pair-uninit.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/transmute_fat1.stderr b/tests/compile-fail/transmute_fat1.stderr new file mode 100644 index 0000000000..2966f04200 --- /dev/null +++ b/tests/compile-fail/transmute_fat1.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: unable to turn pointer into raw bytes + --> $DIR/transmute_fat1.rs:LL:CC + | +LL | let _val = bad[0] + bad[bad.len()-1]; + | ^^^^^^ unable to turn pointer into raw bytes + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/transmute_fat1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/type-too-large.stderr b/tests/compile-fail/type-too-large.stderr new file mode 100644 index 0000000000..3d555da40c --- /dev/null +++ b/tests/compile-fail/type-too-large.stderr @@ -0,0 +1,12 @@ +error: post-monomorphization error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture + --> $DIR/type-too-large.rs:LL:CC + | +LL | [0; (1u64<<61) as usize +(1u64<<31) as usize]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843011361177600]` are too big for the current architecture + | + = note: inside `main` at $DIR/type-too-large.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/alignment.rs b/tests/compile-fail/unaligned_pointers/alignment.rs index ff31fc6c29..b77f0eef82 100644 --- a/tests/compile-fail/unaligned_pointers/alignment.rs +++ b/tests/compile-fail/unaligned_pointers/alignment.rs @@ -1,4 +1,5 @@ // error-pattern: but alignment 4 is required +// normalize-stderr-test: "\.add\(1\)" -> " " fn main() { // No retry needed, this fails reliably. @@ -7,7 +8,7 @@ fn main() { let x_ptr: *mut u8 = x.as_mut_ptr(); // At least one of these is definitely unaligned. unsafe { - *(x_ptr as *mut u32) = 42; + *(x_ptr as *mut u32) = 42; *(x_ptr.add(1) as *mut u32) = 42; } } diff --git a/tests/compile-fail/unaligned_pointers/alignment.stderr b/tests/compile-fail/unaligned_pointers/alignment.stderr new file mode 100644 index 0000000000..c21e2ed2ec --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/alignment.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/alignment.rs:LL:CC + | +LL | *(x_ptr as *mut u32) = 42; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/alignment.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/atomic_unaligned.stderr b/tests/compile-fail/unaligned_pointers/atomic_unaligned.stderr new file mode 100644 index 0000000000..f56e6612fb --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/atomic_unaligned.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/atomic_unaligned.rs:LL:CC + | +LL | ::std::intrinsics::atomic_load(zptr); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this usually indicates that your program performed an invalid operation and caused Undefined Behavior + = help: but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives + + = note: inside `main` at $DIR/atomic_unaligned.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/dyn_alignment.rs b/tests/compile-fail/unaligned_pointers/dyn_alignment.rs index 91d9ec475b..9d8829fe1e 100644 --- a/tests/compile-fail/unaligned_pointers/dyn_alignment.rs +++ b/tests/compile-fail/unaligned_pointers/dyn_alignment.rs @@ -16,6 +16,6 @@ fn main() { // Overwrite the data part of `ptr` so it points to `buf`. unsafe { (&mut ptr as *mut _ as *mut *const u8).write(&buf as *const _ as *const u8); } // Re-borrow that. This should be UB. - let _ptr = &*ptr; //~ERROR alignment 256 is required + let _ptr = &*ptr; //~ERROR alignment ALIGN is required } } diff --git a/tests/compile-fail/unaligned_pointers/dyn_alignment.stderr b/tests/compile-fail/unaligned_pointers/dyn_alignment.stderr new file mode 100644 index 0000000000..6c64f0e365 --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/dyn_alignment.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/dyn_alignment.rs:LL:CC + | +LL | let _ptr = &*ptr; + | ^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dyn_alignment.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs b/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs index 9872a493c0..a8d0b5afbb 100644 --- a/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs +++ b/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs @@ -12,6 +12,6 @@ fn main() { // Manually make sure the pointer is properly aligned. let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr+1 }; let u16_ptr = base_addr_aligned as *mut u16; - unsafe { *u16_ptr = 2; } //~ERROR memory with alignment 1, but alignment 2 is required + unsafe { *u16_ptr = 2; } //~ERROR memory with alignment ALIGN, but alignment ALIGN is required println!("{:?}", x); } diff --git a/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.stderr b/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.stderr new file mode 100644 index 0000000000..8e0986c453 --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/intptrcast_alignment_check.rs:LL:CC + | +LL | unsafe { *u16_ptr = 2; } + | ^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this usually indicates that your program performed an invalid operation and caused Undefined Behavior + = help: but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives + + = note: inside `main` at $DIR/intptrcast_alignment_check.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/reference_to_packed.rs b/tests/compile-fail/unaligned_pointers/reference_to_packed.rs index b376859d22..60d2524040 100644 --- a/tests/compile-fail/unaligned_pointers/reference_to_packed.rs +++ b/tests/compile-fail/unaligned_pointers/reference_to_packed.rs @@ -16,6 +16,6 @@ fn main() { y: 99, }; let p = &foo.x; - let i = *p; //~ERROR alignment 4 is required + let i = *p; //~ERROR alignment ALIGN is required } } diff --git a/tests/compile-fail/unaligned_pointers/reference_to_packed.stderr b/tests/compile-fail/unaligned_pointers/reference_to_packed.stderr new file mode 100644 index 0000000000..3dbc47f71d --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/reference_to_packed.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/reference_to_packed.rs:LL:CC + | +LL | let i = *p; + | ^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/reference_to_packed.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs index 1d72e5170b..fe46e7b8ad 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs @@ -6,6 +6,6 @@ fn main() { let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error. let x = &x[0] as *const _ as *const u32; // This must fail because alignment is violated: the allocation's base is not sufficiently aligned. - let _x = unsafe { *x }; //~ERROR memory with alignment 2, but alignment 4 is required + let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required } } diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.stderr new file mode 100644 index 0000000000..afc458e9cc --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr1.rs:LL:CC + | +LL | let _x = unsafe { *x }; + | ^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unaligned_ptr1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs index 49612e2b8a..1d1e7fad05 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs @@ -8,5 +8,5 @@ fn main() { let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32; // This must fail because alignment is violated: the offset is not sufficiently aligned. // Also make the offset not a power of 2, that used to ICE. - let _x = unsafe { *x }; //~ERROR memory with alignment 1, but alignment 4 is required + let _x = unsafe { *x }; //~ERROR memory with alignment ALIGN, but alignment ALIGN is required } diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.stderr new file mode 100644 index 0000000000..ac1ef5c381 --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr2.rs:LL:CC + | +LL | let _x = unsafe { *x }; + | ^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unaligned_ptr2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr3.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr3.stderr new file mode 100644 index 0000000000..7075bb4c7b --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr3.rs:LL:CC + | +LL | let _x = unsafe { *x }; + | ^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unaligned_ptr3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr4.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr4.stderr new file mode 100644 index 0000000000..e72f28682f --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr4.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr4.rs:LL:CC + | +LL | let _val = unsafe { *ptr }; + | ^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unaligned_ptr4.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs index e33f3c8598..d97306b3cb 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs @@ -8,6 +8,6 @@ fn main() { let x = &x[0] as *const _ as *const u32; // This must fail because alignment is violated: the allocation's base is not sufficiently aligned. // The deref is UB even if we just put the result into a raw pointer. - let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required + let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment ALIGN, but alignment ALIGN is required } } diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.stderr new file mode 100644 index 0000000000..b858a291de --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr_addr_of.rs:LL:CC + | +LL | let _x = unsafe { ptr::addr_of!(*x) }; + | ^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at rustc_src/src/ptr/mod.rs:LL:CC + = note: this error originates in the macro `ptr::addr_of` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs index 27403c11ab..c549688c26 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs @@ -7,6 +7,6 @@ fn main() { let x = i as u8; let x = &x as *const _ as *const [u32; 0]; // This must fail because alignment is violated. Test specifically for loading ZST. - let _x = unsafe { *x }; //~ERROR alignment 4 is required + let _x = unsafe { *x }; //~ERROR alignment ALIGN is required } } diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.stderr b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.stderr new file mode 100644 index 0000000000..7ee9a949cc --- /dev/null +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required + --> $DIR/unaligned_ptr_zst.rs:LL:CC + | +LL | let _x = unsafe { *x }; + | ^^ accessing memory with alignment ALIGN, but alignment ALIGN is required + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/unaligned_ptr_zst.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_buffer.stderr b/tests/compile-fail/uninit_buffer.stderr new file mode 100644 index 0000000000..903a1deee3 --- /dev/null +++ b/tests/compile-fail/uninit_buffer.stderr @@ -0,0 +1,23 @@ +error: Undefined Behavior: reading 16 bytes of memory starting at ALLOC, but 12 bytes are uninitialized starting at ALLOC+0x4, and this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `::compare` at rustc_src/src/slice/cmp.rs:LL:CC + = note: inside `core::slice::cmp::::cmp` at rustc_src/src/slice/cmp.rs:LL:CC +note: inside `main` at $DIR/uninit_buffer.rs:LL:CC + --> $DIR/uninit_buffer.rs:LL:CC + | +LL | drop(slice1.cmp(slice2)); + | ^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +Uninitialized read occurred at offsets 0x4..0x10 into this allocation: +ALLOC (Rust heap, size: 32, align: 8) { + 0x00 │ 41 42 43 44 __ __ __ __ __ __ __ __ __ __ __ __ │ ABCD░░░░░░░░░░░░ + 0x10 │ 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ │ .░░░░░░░░░░░░░░░ +} + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_byte_read.stderr b/tests/compile-fail/uninit_byte_read.stderr new file mode 100644 index 0000000000..b07473f95b --- /dev/null +++ b/tests/compile-fail/uninit_byte_read.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + --> $DIR/uninit_byte_read.rs:LL:CC + | +LL | let x = undef + 1; + | ^^^^^^^^^ using uninitialized data, but this operation requires initialized memory + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_byte_read.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_float.stderr b/tests/compile-fail/uninit_float.stderr new file mode 100644 index 0000000000..90cdc3ba0f --- /dev/null +++ b/tests/compile-fail/uninit_float.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + --> $DIR/uninit_float.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_float.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_integer.stderr b/tests/compile-fail/uninit_integer.stderr new file mode 100644 index 0000000000..88b57c1d27 --- /dev/null +++ b/tests/compile-fail/uninit_integer.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + --> $DIR/uninit_integer.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_integer.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_integer_signed.stderr b/tests/compile-fail/uninit_integer_signed.stderr new file mode 100644 index 0000000000..fc15462280 --- /dev/null +++ b/tests/compile-fail/uninit_integer_signed.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + --> $DIR/uninit_integer_signed.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_integer_signed.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/uninit_raw_ptr.stderr b/tests/compile-fail/uninit_raw_ptr.stderr new file mode 100644 index 0000000000..96074fc1e7 --- /dev/null +++ b/tests/compile-fail/uninit_raw_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized raw pointer + --> $DIR/uninit_raw_ptr.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::<*const u8>::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized raw pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_raw_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unreachable.stderr b/tests/compile-fail/unreachable.stderr new file mode 100644 index 0000000000..59ab843319 --- /dev/null +++ b/tests/compile-fail/unreachable.stderr @@ -0,0 +1,16 @@ +error: Undefined Behavior: entering unreachable code + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `std::hint::unreachable_unchecked` at rustc_src/src/hint.rs:LL:CC +note: inside `main` at $DIR/unreachable.rs:LL:CC + --> $DIR/unreachable.rs:LL:CC + | +LL | unsafe { std::hint::unreachable_unchecked() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unsupported_foreign_function.stderr b/tests/compile-fail/unsupported_foreign_function.stderr new file mode 100644 index 0000000000..b8b1925d2c --- /dev/null +++ b/tests/compile-fail/unsupported_foreign_function.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: can't call foreign function: foo + --> $DIR/unsupported_foreign_function.rs:LL:CC + | +LL | foo(); + | ^^^^^ can't call foreign function: foo + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/unsupported_foreign_function.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/unsupported_signal.stderr b/tests/compile-fail/unsupported_signal.stderr new file mode 100644 index 0000000000..8fcbc7fb47 --- /dev/null +++ b/tests/compile-fail/unsupported_signal.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: can't call foreign function: signal + --> $DIR/unsupported_signal.rs:LL:CC + | +LL | libc::signal(libc::SIGPIPE, libc::SIG_IGN); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: signal + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + + = note: inside `main` at $DIR/unsupported_signal.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/cast_fn_ptr1.stderr b/tests/compile-fail/validity/cast_fn_ptr1.stderr new file mode 100644 index 0000000000..d048377a77 --- /dev/null +++ b/tests/compile-fail/validity/cast_fn_ptr1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a null reference + --> $DIR/cast_fn_ptr1.rs:LL:CC + | +LL | g(0usize as *const i32) + | ^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null reference + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/cast_fn_ptr2.stderr b/tests/compile-fail/validity/cast_fn_ptr2.stderr new file mode 100644 index 0000000000..10b9b9b860 --- /dev/null +++ b/tests/compile-fail/validity/cast_fn_ptr2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a null reference + --> $DIR/cast_fn_ptr2.rs:LL:CC + | +LL | let _x = g(); + | ^^^ type validation failed: encountered a null reference + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/cast_fn_ptr2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/dangling_ref1.rs b/tests/compile-fail/validity/dangling_ref1.rs index 78425cde4a..3243eee06e 100644 --- a/tests/compile-fail/validity/dangling_ref1.rs +++ b/tests/compile-fail/validity/dangling_ref1.rs @@ -3,5 +3,5 @@ use std::mem; fn main() { - let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address 0x10 is unallocated) + let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated) } diff --git a/tests/compile-fail/validity/dangling_ref1.stderr b/tests/compile-fail/validity/dangling_ref1.stderr new file mode 100644 index 0000000000..0d358fd7f7 --- /dev/null +++ b/tests/compile-fail/validity/dangling_ref1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x10 is unallocated) + --> $DIR/dangling_ref1.rs:LL:CC + | +LL | let _x: &i32 = unsafe { mem::transmute(16usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (address 0x10 is unallocated) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_ref1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/dangling_ref2.stderr b/tests/compile-fail/validity/dangling_ref2.stderr new file mode 100644 index 0000000000..e3bbb72fdc --- /dev/null +++ b/tests/compile-fail/validity/dangling_ref2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a dangling reference (going beyond the bounds of its allocation) + --> $DIR/dangling_ref2.rs:LL:CC + | +LL | let _x: &i32 = unsafe { mem::transmute(ptr) }; + | ^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (going beyond the bounds of its allocation) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_ref2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/dangling_ref3.stderr b/tests/compile-fail/validity/dangling_ref3.stderr new file mode 100644 index 0000000000..5842eca9fc --- /dev/null +++ b/tests/compile-fail/validity/dangling_ref3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a dangling reference (use-after-free) + --> $DIR/dangling_ref3.rs:LL:CC + | +LL | let _x: &i32 = unsafe { mem::transmute(dangling()) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a dangling reference (use-after-free) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/dangling_ref3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_bool.rs b/tests/compile-fail/validity/invalid_bool.rs index 0b2d648d02..df6c19df7f 100644 --- a/tests/compile-fail/validity/invalid_bool.rs +++ b/tests/compile-fail/validity/invalid_bool.rs @@ -1,3 +1,3 @@ fn main() { - let _b = unsafe { std::mem::transmute::(2) }; //~ ERROR encountered 0x02, but expected a boolean + let _b = unsafe { std::mem::transmute::(2) }; //~ ERROR expected a boolean } diff --git a/tests/compile-fail/validity/invalid_bool.stderr b/tests/compile-fail/validity/invalid_bool.stderr new file mode 100644 index 0000000000..d17319d2dc --- /dev/null +++ b/tests/compile-fail/validity/invalid_bool.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered 0x02, but expected a boolean + --> $DIR/invalid_bool.rs:LL:CC + | +LL | let _b = unsafe { std::mem::transmute::(2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0x02, but expected a boolean + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_bool.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_bool_uninit.stderr b/tests/compile-fail/validity/invalid_bool_uninit.stderr new file mode 100644 index 0000000000..e262e69dc6 --- /dev/null +++ b/tests/compile-fail/validity/invalid_bool_uninit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered uninitialized bytes, but expected a boolean + --> $DIR/invalid_bool_uninit.rs:LL:CC + | +LL | let _b = unsafe { MyUninit { init: () }.uninit }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a boolean + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_bool_uninit.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_char.rs b/tests/compile-fail/validity/invalid_char.rs index 079823f894..d9a55f241c 100644 --- a/tests/compile-fail/validity/invalid_char.rs +++ b/tests/compile-fail/validity/invalid_char.rs @@ -1,6 +1,6 @@ fn main() { assert!(std::char::from_u32(-1_i32 as u32).is_none()); - let _val = match unsafe { std::mem::transmute::(-1) } { //~ ERROR encountered 0xffffffff, but expected a valid unicode scalar value + let _val = match unsafe { std::mem::transmute::(-1) } { //~ ERROR encountered $HEX, but expected a valid unicode scalar value 'a' => {true}, 'b' => {false}, _ => {true}, diff --git a/tests/compile-fail/validity/invalid_char.stderr b/tests/compile-fail/validity/invalid_char.stderr new file mode 100644 index 0000000000..99f5ce0bb2 --- /dev/null +++ b/tests/compile-fail/validity/invalid_char.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered $HEX, but expected a valid unicode scalar value (in `0..=$HEX` but not in `$HEX..=$HEX`) + --> $DIR/invalid_char.rs:LL:CC + | +LL | let _val = match unsafe { std::mem::transmute::(-1) } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered $HEX, but expected a valid unicode scalar value (in `0..=$HEX` but not in `$HEX..=$HEX`) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_char.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_char_uninit.rs b/tests/compile-fail/validity/invalid_char_uninit.rs index 34798dfbc6..cb885d001c 100644 --- a/tests/compile-fail/validity/invalid_char_uninit.rs +++ b/tests/compile-fail/validity/invalid_char_uninit.rs @@ -6,5 +6,5 @@ union MyUninit { } fn main() { - let _b = unsafe { MyUninit { init: () }.uninit }; //~ ERROR encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`) + let _b = unsafe { MyUninit { init: () }.uninit }; //~ ERROR encountered uninitialized bytes, but expected a valid unicode scalar value } diff --git a/tests/compile-fail/validity/invalid_char_uninit.stderr b/tests/compile-fail/validity/invalid_char_uninit.stderr new file mode 100644 index 0000000000..b27c9b2bb6 --- /dev/null +++ b/tests/compile-fail/validity/invalid_char_uninit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=$HEX` but not in `$HEX..=$HEX`) + --> $DIR/invalid_char_uninit.rs:LL:CC + | +LL | let _b = unsafe { MyUninit { init: () }.uninit }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a valid unicode scalar value (in `0..=$HEX` but not in `$HEX..=$HEX`) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_char_uninit.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_enum_tag.stderr b/tests/compile-fail/validity/invalid_enum_tag.stderr new file mode 100644 index 0000000000..c6d862ae1b --- /dev/null +++ b/tests/compile-fail/validity/invalid_enum_tag.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .: encountered $HEX, but expected a valid enum tag + --> $DIR/invalid_enum_tag.rs:LL:CC + | +LL | ... { std::mem::transmute::(42) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered $HEX, but expected a valid enum tag + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_enum_tag.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_enum_tag_256variants_uninit.stderr b/tests/compile-fail/validity/invalid_enum_tag_256variants_uninit.stderr new file mode 100644 index 0000000000..1a6039c477 --- /dev/null +++ b/tests/compile-fail/validity/invalid_enum_tag_256variants_uninit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .: encountered uninitialized bytes, but expected a valid enum tag + --> $DIR/invalid_enum_tag_256variants_uninit.rs:LL:CC + | +LL | let _a = unsafe { MyUninit { init: () }.uninit }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .: encountered uninitialized bytes, but expected a valid enum tag + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_enum_tag_256variants_uninit.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_fnptr_null.stderr b/tests/compile-fail/validity/invalid_fnptr_null.stderr new file mode 100644 index 0000000000..e3cea40e0c --- /dev/null +++ b/tests/compile-fail/validity/invalid_fnptr_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a null function pointer + --> $DIR/invalid_fnptr_null.rs:LL:CC + | +LL | let _b: fn() = unsafe { std::mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a null function pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_fnptr_null.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_fnptr_uninit.stderr b/tests/compile-fail/validity/invalid_fnptr_uninit.stderr new file mode 100644 index 0000000000..84a5657e78 --- /dev/null +++ b/tests/compile-fail/validity/invalid_fnptr_uninit.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered uninitialized bytes, but expected a proper pointer or integer value + --> $DIR/invalid_fnptr_uninit.rs:LL:CC + | +LL | let _b = unsafe { MyUninit { init: () }.uninit }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected a proper pointer or integer value + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_fnptr_uninit.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/invalid_wide_raw.stderr b/tests/compile-fail/validity/invalid_wide_raw.stderr new file mode 100644 index 0000000000..f64b824d6b --- /dev/null +++ b/tests/compile-fail/validity/invalid_wide_raw.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered dangling vtable pointer in wide pointer + --> $DIR/invalid_wide_raw.rs:LL:CC + | +LL | dbg!(S { x: unsafe { std::mem::transmute((0usize, 0usize)) } }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling vtable pointer in wide pointer + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/invalid_wide_raw.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/nonzero.stderr b/tests/compile-fail/validity/nonzero.stderr new file mode 100644 index 0000000000..ba01acb6a1 --- /dev/null +++ b/tests/compile-fail/validity/nonzero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered 0, but expected something greater or equal to 1 + --> $DIR/nonzero.rs:LL:CC + | +LL | let _x = Some(unsafe { NonZero(0) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/nonzero.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/ptr_integer_array_transmute.stderr b/tests/compile-fail/validity/ptr_integer_array_transmute.stderr new file mode 100644 index 0000000000..bc2ca54438 --- /dev/null +++ b/tests/compile-fail/validity/ptr_integer_array_transmute.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a pointer, but expected plain (non-pointer) bytes + --> $DIR/ptr_integer_array_transmute.rs:LL:CC + | +LL | let _i: [usize; 1] = unsafe { std::mem::transmute(r) }; + | ^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_integer_array_transmute.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/ptr_integer_transmute.stderr b/tests/compile-fail/validity/ptr_integer_transmute.stderr new file mode 100644 index 0000000000..cad53d71f4 --- /dev/null +++ b/tests/compile-fail/validity/ptr_integer_transmute.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered pointer to $HEX[ALLOC], but expected plain (non-pointer) bytes + --> $DIR/ptr_integer_transmute.rs:LL:CC + | +LL | let _i: usize = unsafe { std::mem::transmute(r) }; + | ^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to $HEX[ALLOC], but expected plain (non-pointer) bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ptr_integer_transmute.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/ref_to_uninhabited1.stderr b/tests/compile-fail/validity/ref_to_uninhabited1.stderr new file mode 100644 index 0000000000..de41944944 --- /dev/null +++ b/tests/compile-fail/validity/ref_to_uninhabited1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a box pointing to uninhabited type ! + --> $DIR/ref_to_uninhabited1.rs:LL:CC + | +LL | let x: Box = transmute(&mut 42); + | ^^^^^^^^^^^^^^^^^^ type validation failed: encountered a box pointing to uninhabited type ! + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ref_to_uninhabited1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/ref_to_uninhabited2.stderr b/tests/compile-fail/validity/ref_to_uninhabited2.stderr new file mode 100644 index 0000000000..754c39e789 --- /dev/null +++ b/tests/compile-fail/validity/ref_to_uninhabited2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered a reference pointing to uninhabited type (i32, Void) + --> $DIR/ref_to_uninhabited2.rs:LL:CC + | +LL | let _x: &(i32, Void) = transmute(&42); + | ^^^^^^^^^^^^^^ type validation failed: encountered a reference pointing to uninhabited type (i32, Void) + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/ref_to_uninhabited2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/too-big-slice.stderr b/tests/compile-fail/validity/too-big-slice.stderr new file mode 100644 index 0000000000..11d20d3e62 --- /dev/null +++ b/tests/compile-fail/validity/too-big-slice.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + --> $DIR/too-big-slice.rs:LL:CC + | +LL | let _x: &[u8] = mem::transmute((ptr, usize::MAX)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: slice is bigger than largest supported object + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/too-big-slice.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/too-big-unsized.stderr b/tests/compile-fail/validity/too-big-unsized.stderr new file mode 100644 index 0000000000..0c7b7b2324 --- /dev/null +++ b/tests/compile-fail/validity/too-big-unsized.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed: encountered invalid reference metadata: total size is bigger than largest supported object + --> $DIR/too-big-unsized.rs:LL:CC + | +LL | let _x: &MySlice = mem::transmute((ptr, isize::MAX as usize)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid reference metadata: total size is bigger than largest supported object + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/too-big-unsized.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/transmute_through_ptr.stderr b/tests/compile-fail/validity/transmute_through_ptr.stderr new file mode 100644 index 0000000000..d06dbe3194 --- /dev/null +++ b/tests/compile-fail/validity/transmute_through_ptr.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .: encountered $HEX, but expected a valid enum tag + --> $DIR/transmute_through_ptr.rs:LL:CC + | +LL | let y = x; // reading this ought to be enough to trigger validation + | ^ type validation failed at .: encountered $HEX, but expected a valid enum tag + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/transmute_through_ptr.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/uninit_float.stderr b/tests/compile-fail/validity/uninit_float.stderr new file mode 100644 index 0000000000..3f244adbab --- /dev/null +++ b/tests/compile-fail/validity/uninit_float.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + --> $DIR/uninit_float.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_float.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/uninit_integer.stderr b/tests/compile-fail/validity/uninit_integer.stderr new file mode 100644 index 0000000000..e3e2f0a178 --- /dev/null +++ b/tests/compile-fail/validity/uninit_integer.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + --> $DIR/uninit_integer.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_integer.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/validity/uninit_integer_signed.stderr b/tests/compile-fail/validity/uninit_integer_signed.stderr new file mode 100644 index 0000000000..e6d9b51e40 --- /dev/null +++ b/tests/compile-fail/validity/uninit_integer_signed.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + --> $DIR/uninit_integer_signed.rs:LL:CC + | +LL | let _val = unsafe { std::mem::MaybeUninit::::uninit().assume_init() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed at .value: encountered uninitialized bytes, but expected initialized bytes + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/uninit_integer_signed.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/zst1.stderr b/tests/compile-fail/zst1.stderr new file mode 100644 index 0000000000..ba13c9d7e5 --- /dev/null +++ b/tests/compile-fail/zst1.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds + --> $DIR/zst1.rs:LL:CC + | +LL | let _val = unsafe { *x }; + | ^^ dereferencing pointer failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/zst1.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/zst2.stderr b/tests/compile-fail/zst2.stderr new file mode 100644 index 0000000000..088bb2a1cc --- /dev/null +++ b/tests/compile-fail/zst2.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed + --> $DIR/zst2.rs:LL:CC + | +LL | unsafe { *x = zst_val; } + | ^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/zst2.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compile-fail/zst3.stderr b/tests/compile-fail/zst3.stderr new file mode 100644 index 0000000000..a7d84dcaad --- /dev/null +++ b/tests/compile-fail/zst3.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds + --> $DIR/zst3.rs:LL:CC + | +LL | unsafe { *(x as *mut [u8; 0]) = zst_val; } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + + = note: inside `main` at $DIR/zst3.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/tests/compiletest.rs b/tests/compiletest.rs index a0d49c9ddc..92a8bd6291 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -1,82 +1,127 @@ +use colored::*; +use regex::Regex; use std::env; use std::path::PathBuf; - -use colored::*; -use compiletest_rs as compiletest; +use ui_test::{Config, Mode, OutputConflictHandling}; fn miri_path() -> PathBuf { PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri"))) } -fn run_tests(mode: &str, path: &str, target: &str) { +fn run_tests(mode: Mode, path: &str, target: Option) { let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some(); + // Add some flags we always want. let mut flags = Vec::new(); - flags.push("--edition 2018".to_owned()); + flags.push("--edition".to_owned()); + flags.push("2018".to_owned()); if in_rustc_test_suite { // Less aggressive warnings to make the rustc toolstate management less painful. // (We often get warnings when e.g. a feature gets stabilized or some lint gets added/improved.) flags.push("-Astable-features".to_owned()); } else { - flags.push("-Dwarnings -Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs + flags.push("-Dwarnings".to_owned()); + flags.push("-Dunused".to_owned()); // overwrite the -Aunused in compiletest-rs } if let Ok(sysroot) = env::var("MIRI_SYSROOT") { - flags.push(format!("--sysroot {}", sysroot)); + flags.push("--sysroot".to_string()); + flags.push(sysroot); } if let Ok(extra_flags) = env::var("MIRIFLAGS") { - flags.push(extra_flags); + for flag in extra_flags.split_whitespace() { + flags.push(flag.to_string()); + } + } + flags.push("-Zui-testing".to_string()); + if let Some(target) = &target { + flags.push("--target".to_string()); + flags.push(target.clone()); } - let flags = flags.join(" "); - eprintln!(" Compiler flags: {}", flags); + let skip_ui_checks = in_rustc_test_suite || env::var_os("MIRI_SKIP_UI_CHECKS").is_some(); - // The rest of the configuration. - let mut config = compiletest::Config::default().tempdir(); - config.mode = mode.parse().expect("Invalid mode"); - config.rustc_path = miri_path(); - if let Some(lib_path) = option_env!("RUSTC_LIB_PATH") { - config.run_lib_path = PathBuf::from(lib_path); - config.compile_lib_path = PathBuf::from(lib_path); - } - config.filters = env::args().nth(1).into_iter().collect(); - config.host = get_host(); - config.src_base = PathBuf::from(path); - config.target = target.to_owned(); - config.target_rustcflags = Some(flags); - compiletest::run_tests(&config); -} + let output_conflict_handling = match (env::var_os("MIRI_BLESS").is_some(), skip_ui_checks) { + (false, false) => OutputConflictHandling::Error, + (true, false) => OutputConflictHandling::Bless, + (false, true) => OutputConflictHandling::Ignore, + (true, true) => panic!("cannot use MIRI_BLESS and MIRI_SKIP_UI_CHECKS at the same time"), + }; -fn compile_fail(path: &str, target: &str) { - eprintln!( - "{}", - format!("## Running compile-fail tests in {} against miri for target {}", path, target) - .green() - .bold() - ); + let config = Config { + args: flags, + target, + stderr_filters: STDERR.clone(), + stdout_filters: STDOUT.clone(), + root_dir: PathBuf::from(path), + mode, + program: miri_path(), + output_conflict_handling, + }; + ui_test::run_tests(config) +} - run_tests("compile-fail", path, target); +macro_rules! regexes { + ($name:ident: $($regex:expr => $replacement:expr,)*) => {lazy_static::lazy_static! { + static ref $name: Vec<(Regex, &'static str)> = vec![ + $((Regex::new($regex).unwrap(), $replacement),)* + ]; + }}; } -fn miri_pass(path: &str, target: &str) { - eprintln!( - "{}", - format!("## Running run-pass tests in {} against miri for target {}", path, target) - .green() - .bold() - ); +regexes! { + STDOUT: + // Windows file paths + r"\\" => "/", +} - run_tests("ui", path, target); +regexes! { + STDERR: + // erase line and column info + r"\.rs:[0-9]+:[0-9]+" => ".rs:LL:CC", + // erase alloc ids + "alloc[0-9]+" => "ALLOC", + // erase Stacked Borrows tags + "<[0-9]+>" => "", + // erase whitespace that differs between platforms + r" +at (.*\.rs)" => " at $1", + // erase generics in backtraces + "([0-9]+: .*)::<.*>" => "$1", + // erase addresses in backtraces + "([0-9]+: ) +0x[0-9a-f]+ - (.*)" => "$1$2", + // erase long hexadecimals + r"0x[0-9a-fA-F]+[0-9a-fA-F]{2,2}" => "$$HEX", + // erase clocks + r"VClock\(\[[^\]]+\]\)" => "VClock", + // erase specific alignments + "alignment [0-9]+" => "alignment ALIGN", + // erase thread caller ids + r"\(call [0-9]+\)" => "(call ID)", + // erase platform module paths + "sys::[a-z]+::" => "sys::PLATFORM::", + // Windows file paths + r"\\" => "/", + // erase platform file paths + "sys/[a-z]+/" => "sys/PLATFORM/", + // erase error annotations in tests + r"\s*//~.*" => "", } -fn get_host() -> String { - let version_meta = - rustc_version::VersionMeta::for_command(std::process::Command::new(miri_path())) - .expect("failed to parse rustc version info"); - version_meta.host +fn ui(mode: Mode, path: &str) { + let target = get_target(); + + eprint!("{}", format!("## Running ui tests in {path} against miri for ").green().bold()); + + if let Some(target) = &target { + eprintln!("{target}"); + } else { + eprintln!("host"); + } + + run_tests(mode, path, target); } -fn get_target() -> String { - env::var("MIRI_TEST_TARGET").unwrap_or_else(|_| get_host()) +fn get_target() -> Option { + env::var("MIRI_TEST_TARGET").ok() } fn main() { @@ -84,10 +129,8 @@ fn main() { env::set_var("MIRI_ENV_VAR_TEST", "0"); // Let the tests know where to store temp files (they might run for a different target, which can make this hard to find). env::set_var("MIRI_TEMP", env::temp_dir()); - // Panic tests expect backtraces to be printed. - env::set_var("RUST_BACKTRACE", "1"); - let target = get_target(); - miri_pass("tests/run-pass", &target); - compile_fail("tests/compile-fail", &target); + ui(Mode::Pass, "tests/run-pass"); + ui(Mode::Panic, "tests/run-fail"); + ui(Mode::Fail, "tests/compile-fail"); } diff --git a/tests/run-pass/function_calls/exported_symbol_good_unwind.rs b/tests/run-fail/function_calls/exported_symbol_good_unwind.rs similarity index 100% rename from tests/run-pass/function_calls/exported_symbol_good_unwind.rs rename to tests/run-fail/function_calls/exported_symbol_good_unwind.rs diff --git a/tests/run-pass/function_calls/exported_symbol_good_unwind.stderr b/tests/run-fail/function_calls/exported_symbol_good_unwind.stderr similarity index 80% rename from tests/run-pass/function_calls/exported_symbol_good_unwind.stderr rename to tests/run-fail/function_calls/exported_symbol_good_unwind.stderr index 40a8f39509..bff897775e 100644 --- a/tests/run-pass/function_calls/exported_symbol_good_unwind.stderr +++ b/tests/run-fail/function_calls/exported_symbol_good_unwind.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:11:5 +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:16:5 -thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:22:5 +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC +thread 'main' panicked at 'explicit panic', $DIR/exported_symbol_good_unwind.rs:LL:CC diff --git a/tests/run-pass/panic/div-by-zero-2.rs b/tests/run-fail/panic/div-by-zero-2.rs similarity index 100% rename from tests/run-pass/panic/div-by-zero-2.rs rename to tests/run-fail/panic/div-by-zero-2.rs diff --git a/tests/run-pass/panic/div-by-zero-2.stderr b/tests/run-fail/panic/div-by-zero-2.stderr similarity index 88% rename from tests/run-pass/panic/div-by-zero-2.stderr rename to tests/run-fail/panic/div-by-zero-2.stderr index 60ff33c8bf..538d871136 100644 --- a/tests/run-pass/panic/div-by-zero-2.stderr +++ b/tests/run-fail/panic/div-by-zero-2.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:4:14 +thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-lsh-neg.rs b/tests/run-fail/panic/overflowing-lsh-neg.rs similarity index 100% rename from tests/run-pass/panic/overflowing-lsh-neg.rs rename to tests/run-fail/panic/overflowing-lsh-neg.rs diff --git a/tests/run-pass/panic/overflowing-lsh-neg.stderr b/tests/run-fail/panic/overflowing-lsh-neg.stderr similarity index 80% rename from tests/run-pass/panic/overflowing-lsh-neg.stderr rename to tests/run-fail/panic/overflowing-lsh-neg.stderr index 64959da0fa..21e434d873 100644 --- a/tests/run-pass/panic/overflowing-lsh-neg.stderr +++ b/tests/run-fail/panic/overflowing-lsh-neg.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:4:14 +thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-rsh-1.rs b/tests/run-fail/panic/overflowing-rsh-1.rs similarity index 100% rename from tests/run-pass/panic/overflowing-rsh-1.rs rename to tests/run-fail/panic/overflowing-rsh-1.rs diff --git a/tests/run-pass/panic/overflowing-rsh-1.stderr b/tests/run-fail/panic/overflowing-rsh-1.stderr similarity index 80% rename from tests/run-pass/panic/overflowing-rsh-1.stderr rename to tests/run-fail/panic/overflowing-rsh-1.stderr index bd8843f8d6..fd04bf1bd4 100644 --- a/tests/run-pass/panic/overflowing-rsh-1.stderr +++ b/tests/run-fail/panic/overflowing-rsh-1.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:4:14 +thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/overflowing-rsh-2.rs b/tests/run-fail/panic/overflowing-rsh-2.rs similarity index 100% rename from tests/run-pass/panic/overflowing-rsh-2.rs rename to tests/run-fail/panic/overflowing-rsh-2.rs diff --git a/tests/run-pass/panic/overflowing-rsh-2.stderr b/tests/run-fail/panic/overflowing-rsh-2.stderr similarity index 80% rename from tests/run-pass/panic/overflowing-rsh-2.stderr rename to tests/run-fail/panic/overflowing-rsh-2.stderr index c43090ea70..eb568e4d74 100644 --- a/tests/run-pass/panic/overflowing-rsh-2.stderr +++ b/tests/run-fail/panic/overflowing-rsh-2.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:5:14 +thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-fail/panic/panic1.rs b/tests/run-fail/panic/panic1.rs new file mode 100644 index 0000000000..cfaa642beb --- /dev/null +++ b/tests/run-fail/panic/panic1.rs @@ -0,0 +1,7 @@ +// rustc-env: RUST_BACKTRACE=1 +// compile-flags: -Zmiri-disable-isolation + + +fn main() { + std::panic!("panicking from libstd"); +} diff --git a/tests/run-pass/panic/panic1.stderr b/tests/run-fail/panic/panic1.stderr similarity index 55% rename from tests/run-pass/panic/panic1.stderr rename to tests/run-fail/panic/panic1.stderr index 0b59b2a523..d4dcfc47a8 100644 --- a/tests/run-pass/panic/panic1.stderr +++ b/tests/run-fail/panic/panic1.stderr @@ -1,31 +1,31 @@ -thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:8:5 +thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:LL:CC stack backtrace: 0: std::rt::begin_panic - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panicking.rs:LL:CC 1: main - at $DIR/panic1.rs:8:5 + at $DIR/panic1.rs:LL:CC 2: >::call_once - shim(fn()) - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/ops/function.rs:LL:CC 3: std::rt::lang_start::{closure#0} - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/rt.rs:LL:CC 4: std::ops::function::impls::call_once - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/ops/function.rs:LL:CC 5: std::panicking::r#try::do_call - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panicking.rs:LL:CC 6: std::panicking::r#try - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panicking.rs:LL:CC 7: std::panic::catch_unwind - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panic.rs:LL:CC 8: std::rt::lang_start_internal::{closure#2} - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/rt.rs:LL:CC 9: std::panicking::r#try::do_call - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panicking.rs:LL:CC 10: std::panicking::r#try - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panicking.rs:LL:CC 11: std::panic::catch_unwind - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/panic.rs:LL:CC 12: std::rt::lang_start_internal - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/rt.rs:LL:CC 13: std::rt::lang_start - at RUSTLIB/$FILE:LL:COL + at rustc_src/src/rt.rs:LL:CC note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/run-pass/panic/panic2.rs b/tests/run-fail/panic/panic2.rs similarity index 100% rename from tests/run-pass/panic/panic2.rs rename to tests/run-fail/panic/panic2.rs diff --git a/tests/run-pass/panic/panic2.stderr b/tests/run-fail/panic/panic2.stderr similarity index 92% rename from tests/run-pass/panic/panic2.stderr rename to tests/run-fail/panic/panic2.stderr index c0415b4e70..c192ca3f64 100644 --- a/tests/run-pass/panic/panic2.stderr +++ b/tests/run-fail/panic/panic2.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:2:5 +thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/panic3.rs b/tests/run-fail/panic/panic3.rs similarity index 100% rename from tests/run-pass/panic/panic3.rs rename to tests/run-fail/panic/panic3.rs diff --git a/tests/run-pass/panic/panic3.stderr b/tests/run-fail/panic/panic3.stderr similarity index 94% rename from tests/run-pass/panic/panic3.stderr rename to tests/run-fail/panic/panic3.stderr index 8aa8761aeb..0ce4a37fd5 100644 --- a/tests/run-pass/panic/panic3.stderr +++ b/tests/run-fail/panic/panic3.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:2:5 +thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/panic4.rs b/tests/run-fail/panic/panic4.rs similarity index 100% rename from tests/run-pass/panic/panic4.rs rename to tests/run-fail/panic/panic4.rs diff --git a/tests/run-pass/panic/panic4.stderr b/tests/run-fail/panic/panic4.stderr similarity index 92% rename from tests/run-pass/panic/panic4.stderr rename to tests/run-fail/panic/panic4.stderr index a71d25b74c..82df953b61 100644 --- a/tests/run-pass/panic/panic4.stderr +++ b/tests/run-fail/panic/panic4.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:2:5 +thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/unsupported_foreign_function.rs b/tests/run-fail/panic/unsupported_foreign_function.rs similarity index 100% rename from tests/run-pass/panic/unsupported_foreign_function.rs rename to tests/run-fail/panic/unsupported_foreign_function.rs diff --git a/tests/run-pass/panic/unsupported_foreign_function.stderr b/tests/run-fail/panic/unsupported_foreign_function.stderr similarity index 95% rename from tests/run-pass/panic/unsupported_foreign_function.stderr rename to tests/run-fail/panic/unsupported_foreign_function.stderr index bd7f3490d8..9af3e48655 100644 --- a/tests/run-pass/panic/unsupported_foreign_function.stderr +++ b/tests/run-fail/panic/unsupported_foreign_function.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function: foo', $DIR/unsupported_foreign_function.rs:9:9 +thread 'main' panicked at 'unsupported Miri functionality: can't call foreign function: foo', $DIR/unsupported_foreign_function.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/panic/unsupported_syscall.rs b/tests/run-fail/panic/unsupported_syscall.rs similarity index 78% rename from tests/run-pass/panic/unsupported_syscall.rs rename to tests/run-fail/panic/unsupported_syscall.rs index 854f179392..2e62a5d8ae 100644 --- a/tests/run-pass/panic/unsupported_syscall.rs +++ b/tests/run-fail/panic/unsupported_syscall.rs @@ -1,5 +1,5 @@ // ignore-windows: No libc on Windows -// ignore-macos: `syscall` is not supported on macOS +// ignore-apple: `syscall` is not supported on macOS // compile-flags: -Zmiri-panic-on-unsupported #![feature(rustc_private)] diff --git a/tests/run-pass/panic/unsupported_syscall.stderr b/tests/run-fail/panic/unsupported_syscall.stderr similarity index 69% rename from tests/run-pass/panic/unsupported_syscall.stderr rename to tests/run-fail/panic/unsupported_syscall.stderr index 49796ee202..90aa5a9073 100644 --- a/tests/run-pass/panic/unsupported_syscall.stderr +++ b/tests/run-fail/panic/unsupported_syscall.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'unsupported Miri functionality: can't execute syscall with ID 0', $DIR/unsupported_syscall.rs:10:9 +thread 'main' panicked at 'unsupported Miri functionality: can't execute syscall with ID 0', $DIR/unsupported_syscall.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/transmute_fat2.rs b/tests/run-fail/transmute_fat2.rs similarity index 100% rename from tests/run-pass/transmute_fat2.rs rename to tests/run-fail/transmute_fat2.rs diff --git a/tests/run-pass/transmute_fat2.stderr b/tests/run-fail/transmute_fat2.stderr similarity index 75% rename from tests/run-pass/transmute_fat2.stderr rename to tests/run-fail/transmute_fat2.stderr index 54ccdfb5e4..f497ab6725 100644 --- a/tests/run-pass/transmute_fat2.stderr +++ b/tests/run-fail/transmute_fat2.stderr @@ -1,2 +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 +thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/run-pass/backtrace-api-v0.rs b/tests/run-pass/backtrace-api-v0.rs index cb3706e9f5..62702c088d 100644 --- a/tests/run-pass/backtrace-api-v0.rs +++ b/tests/run-pass/backtrace-api-v0.rs @@ -1,6 +1,4 @@ -// normalize-stderr-test ".*/(rust[^/]*|checkout)/library/" -> "RUSTLIB/" -// normalize-stderr-test "RUSTLIB/(.*):\d+:\d+ "-> "RUSTLIB/$1:LL:COL " -// normalize-stderr-test "::<.*>" -> "" +// normalize-stderr-test: "::<.*>" -> "" #[inline(never)] fn func_a() -> Box<[*mut ()]> { func_b::() } #[inline(never)] fn func_b() -> Box<[*mut ()]> { func_c() } diff --git a/tests/run-pass/backtrace-api-v0.stderr b/tests/run-pass/backtrace-api-v0.stderr index 8a697a44ea..d81f5ad1d6 100644 --- a/tests/run-pass/backtrace-api-v0.stderr +++ b/tests/run-pass/backtrace-api-v0.stderr @@ -1,18 +1,18 @@ -$DIR/backtrace-api-v0.rs:13:59 (func_d) -$DIR/backtrace-api-v0.rs:12:50 (func_c) -$DIR/backtrace-api-v0.rs:6:53 (func_b) -$DIR/backtrace-api-v0.rs:5:50 (func_a) -$DIR/backtrace-api-v0.rs:17:18 (main) -RUSTLIB/core/src/ops/function.rs:LL:COL (>::call_once - shim(fn())) -RUSTLIB/std/src/sys_common/backtrace.rs:LL:COL (std::sys_common::backtrace::__rust_begin_short_backtrace) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start::{closure#0}) -RUSTLIB/core/src/ops/function.rs:LL:COL (std::ops::function::impls::call_once) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:COL (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start_internal::{closure#2}) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:COL (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start_internal) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start) +$DIR/backtrace-api-v0.rs:LL:CC (func_d) +$DIR/backtrace-api-v0.rs:LL:CC (func_c) +$DIR/backtrace-api-v0.rs:LL:CC (func_b) +$DIR/backtrace-api-v0.rs:LL:CC (func_a) +$DIR/backtrace-api-v0.rs:LL:CC (main) +rustc_src/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) +rustc_src/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) +rustc_src/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try) +rustc_src/src/panic.rs:LL:CC (std::panic::catch_unwind) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2}) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try) +rustc_src/src/panic.rs:LL:CC (std::panic::catch_unwind) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start_internal) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start) diff --git a/tests/run-pass/backtrace-api-v0.stdout b/tests/run-pass/backtrace-api-v0.stdout index c80a3f3bbc..9de1d034bb 100644 --- a/tests/run-pass/backtrace-api-v0.stdout +++ b/tests/run-pass/backtrace-api-v0.stdout @@ -1,5 +1,5 @@ -$DIR/backtrace-api-v0.rs:13:59 (func_d) -$DIR/backtrace-api-v0.rs:12:50 (func_c) -$DIR/backtrace-api-v0.rs:6:53 (func_b::) -$DIR/backtrace-api-v0.rs:5:50 (func_a) -$DIR/backtrace-api-v0.rs:17:18 (main) +$DIR/backtrace-api-v0.rs:11:59 (func_d) +$DIR/backtrace-api-v0.rs:10:50 (func_c) +$DIR/backtrace-api-v0.rs:4:53 (func_b) +$DIR/backtrace-api-v0.rs:3:50 (func_a) +$DIR/backtrace-api-v0.rs:15:18 (main) diff --git a/tests/run-pass/backtrace-api-v1.rs b/tests/run-pass/backtrace-api-v1.rs index 58ed63eaf3..6d4a29c954 100644 --- a/tests/run-pass/backtrace-api-v1.rs +++ b/tests/run-pass/backtrace-api-v1.rs @@ -1,6 +1,4 @@ -// normalize-stderr-test ".*/(rust[^/]*|checkout)/library/" -> "RUSTLIB/" -// normalize-stderr-test "RUSTLIB/(.*):\d+:\d+ "-> "RUSTLIB/$1:LL:COL " -// normalize-stderr-test "::<.*>" -> "" +// normalize-stderr-test: "::<.*>" -> "" #[inline(never)] fn func_a() -> Box<[*mut ()]> { func_b::() } #[inline(never)] fn func_b() -> Box<[*mut ()]> { func_c() } diff --git a/tests/run-pass/backtrace-api-v1.stderr b/tests/run-pass/backtrace-api-v1.stderr index 806a1c60f5..87c59f4269 100644 --- a/tests/run-pass/backtrace-api-v1.stderr +++ b/tests/run-pass/backtrace-api-v1.stderr @@ -1,18 +1,18 @@ -$DIR/backtrace-api-v1.rs:13:144 (func_d) -$DIR/backtrace-api-v1.rs:12:50 (func_c) -$DIR/backtrace-api-v1.rs:6:53 (func_b) -$DIR/backtrace-api-v1.rs:5:50 (func_a) -$DIR/backtrace-api-v1.rs:17:18 (main) -RUSTLIB/core/src/ops/function.rs:LL:COL (>::call_once - shim(fn())) -RUSTLIB/std/src/sys_common/backtrace.rs:LL:COL (std::sys_common::backtrace::__rust_begin_short_backtrace) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start::{closure#0}) -RUSTLIB/core/src/ops/function.rs:LL:COL (std::ops::function::impls::call_once) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:COL (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start_internal::{closure#2}) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:COL (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:COL (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start_internal) -RUSTLIB/std/src/rt.rs:LL:COL (std::rt::lang_start) +$DIR/backtrace-api-v1.rs:LL:CC (func_d) +$DIR/backtrace-api-v1.rs:LL:CC (func_c) +$DIR/backtrace-api-v1.rs:LL:CC (func_b) +$DIR/backtrace-api-v1.rs:LL:CC (func_a) +$DIR/backtrace-api-v1.rs:LL:CC (main) +rustc_src/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) +rustc_src/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) +rustc_src/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try) +rustc_src/src/panic.rs:LL:CC (std::panic::catch_unwind) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2}) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +rustc_src/src/panicking.rs:LL:CC (std::panicking::r#try) +rustc_src/src/panic.rs:LL:CC (std::panic::catch_unwind) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start_internal) +rustc_src/src/rt.rs:LL:CC (std::rt::lang_start) diff --git a/tests/run-pass/backtrace-api-v1.stdout b/tests/run-pass/backtrace-api-v1.stdout index 2670d560eb..b820a1be0a 100644 --- a/tests/run-pass/backtrace-api-v1.stdout +++ b/tests/run-pass/backtrace-api-v1.stdout @@ -1,5 +1,5 @@ -$DIR/backtrace-api-v1.rs:13:144 (func_d) -$DIR/backtrace-api-v1.rs:12:50 (func_c) -$DIR/backtrace-api-v1.rs:6:53 (func_b::) -$DIR/backtrace-api-v1.rs:5:50 (func_a) -$DIR/backtrace-api-v1.rs:17:18 (main) +$DIR/backtrace-api-v1.rs:11:144 (func_d) +$DIR/backtrace-api-v1.rs:10:50 (func_c) +$DIR/backtrace-api-v1.rs:4:53 (func_b) +$DIR/backtrace-api-v1.rs:3:50 (func_a) +$DIR/backtrace-api-v1.rs:15:18 (main) diff --git a/tests/run-pass/backtrace-std.rs b/tests/run-pass/backtrace-std.rs index 9b61aabab3..64b7e7293b 100644 --- a/tests/run-pass/backtrace-std.rs +++ b/tests/run-pass/backtrace-std.rs @@ -1,6 +1,3 @@ -// normalize-stderr-test "at .*/(rust[^/]*|checkout)/library/" -> "at RUSTLIB/" -// normalize-stderr-test "RUSTLIB/([^:]*):\d+:\d+"-> "RUSTLIB/$1:LL:CC" -// normalize-stderr-test "::<.*>" -> "" // compile-flags: -Zmiri-disable-isolation #![feature(backtrace)] diff --git a/tests/run-pass/backtrace-std.stderr b/tests/run-pass/backtrace-std.stderr index 64386085c7..848ccaea1b 100644 --- a/tests/run-pass/backtrace-std.stderr +++ b/tests/run-pass/backtrace-std.stderr @@ -1,36 +1,36 @@ 0: func_d - at $DIR/backtrace-std.rs:18:45 + at $DIR/backtrace-std.rs:LL:CC 1: func_c - at $DIR/backtrace-std.rs:17:45 + at $DIR/backtrace-std.rs:LL:CC 2: func_b - at $DIR/backtrace-std.rs:11:48 + at $DIR/backtrace-std.rs:LL:CC 3: func_a - at $DIR/backtrace-std.rs:10:45 + at $DIR/backtrace-std.rs:LL:CC 4: main - at $DIR/backtrace-std.rs:21:19 + at $DIR/backtrace-std.rs:LL:CC 5: >::call_once - shim(fn()) - at RUSTLIB/core/src/ops/function.rs:LL:CC + at rustc_src/src/ops/function.rs:LL:CC 6: std::sys_common::backtrace::__rust_begin_short_backtrace - at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC + at rustc_src/src/sys_common/backtrace.rs:LL:CC 7: std::rt::lang_start::{closure#0} - at RUSTLIB/std/src/rt.rs:LL:CC + at rustc_src/src/rt.rs:LL:CC 8: std::ops::function::impls::call_once - at RUSTLIB/core/src/ops/function.rs:LL:CC + at rustc_src/src/ops/function.rs:LL:CC 9: std::panicking::r#try::do_call - at RUSTLIB/std/src/panicking.rs:LL:CC + at rustc_src/src/panicking.rs:LL:CC 10: std::panicking::r#try - at RUSTLIB/std/src/panicking.rs:LL:CC + at rustc_src/src/panicking.rs:LL:CC 11: std::panic::catch_unwind - at RUSTLIB/std/src/panic.rs:LL:CC + at rustc_src/src/panic.rs:LL:CC 12: std::rt::lang_start_internal::{closure#2} - at RUSTLIB/std/src/rt.rs:LL:CC + at rustc_src/src/rt.rs:LL:CC 13: std::panicking::r#try::do_call - at RUSTLIB/std/src/panicking.rs:LL:CC + at rustc_src/src/panicking.rs:LL:CC 14: std::panicking::r#try - at RUSTLIB/std/src/panicking.rs:LL:CC + at rustc_src/src/panicking.rs:LL:CC 15: std::panic::catch_unwind - at RUSTLIB/std/src/panic.rs:LL:CC + at rustc_src/src/panic.rs:LL:CC 16: std::rt::lang_start_internal - at RUSTLIB/std/src/rt.rs:LL:CC + at rustc_src/src/rt.rs:LL:CC 17: std::rt::lang_start - at RUSTLIB/std/src/rt.rs:LL:CC + at rustc_src/src/rt.rs:LL:CC diff --git a/tests/run-pass/concurrency/disable_data_race_detector.rs b/tests/run-pass/concurrency/disable_data_race_detector.rs index 8b2d180f11..14e2d5651d 100644 --- a/tests/run-pass/concurrency/disable_data_race_detector.rs +++ b/tests/run-pass/concurrency/disable_data_race_detector.rs @@ -19,7 +19,7 @@ pub fn main() { }); let j2 = spawn(move || { - *c.0 = 64; //~ ERROR Data race (but not detected as the detector is disabled) + *c.0 = 64; // Data race (but not detected as the detector is disabled) }); j1.join().unwrap(); diff --git a/tests/run-pass/concurrency/libc_pthread_cond.rs b/tests/run-pass/concurrency/libc_pthread_cond.rs index 0e09ec9126..631675aaaf 100644 --- a/tests/run-pass/concurrency/libc_pthread_cond.rs +++ b/tests/run-pass/concurrency/libc_pthread_cond.rs @@ -1,5 +1,5 @@ // ignore-windows: No libc on Windows -// ignore-macos: pthread_condattr_setclock is not supported on MacOS. +// ignore-apple: pthread_condattr_setclock is not supported on MacOS. // compile-flags: -Zmiri-disable-isolation -Zmiri-check-number-validity #![feature(rustc_private)] diff --git a/tests/run-pass/concurrency/linux-futex.rs b/tests/run-pass/concurrency/linux-futex.rs index 4ac928398e..8a67e0b525 100644 --- a/tests/run-pass/concurrency/linux-futex.rs +++ b/tests/run-pass/concurrency/linux-futex.rs @@ -1,7 +1,4 @@ -// Unfortunately, the test framework does not support 'only-linux', -// so we need to ignore Windows and macOS instead. -// ignore-macos: Uses Linux-only APIs -// ignore-windows: Uses Linux-only APIs +// only-linux // compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] diff --git a/tests/run-pass/concurrency/simple.stderr b/tests/run-pass/concurrency/simple.stderr index 35f5f10274..bb60638bd6 100644 --- a/tests/run-pass/concurrency/simple.stderr +++ b/tests/run-pass/concurrency/simple.stderr @@ -1,5 +1,5 @@ warning: thread support is experimental and incomplete: weak memory effects are not emulated. -thread '' panicked at 'Hello!', $DIR/simple.rs:55:9 +thread '' panicked at 'Hello!', $DIR/simple.rs:LL:CC note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:65:9 +thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:LL:CC diff --git a/tests/run-pass/current_dir_with_isolation.rs b/tests/run-pass/current_dir_with_isolation.rs index b5fe6114b2..98c44d57b6 100644 --- a/tests/run-pass/current_dir_with_isolation.rs +++ b/tests/run-pass/current_dir_with_isolation.rs @@ -1,6 +1,6 @@ // compile-flags: -Zmiri-isolation-error=warn-nobacktrace -// normalize-stderr-test "(getcwd|GetCurrentDirectoryW)" -> "$$GETCWD" -// normalize-stderr-test "(chdir|SetCurrentDirectoryW)" -> "$$SETCWD" +// normalize-stderr-test: "(getcwd|GetCurrentDirectoryW)" -> "$$GETCWD" +// normalize-stderr-test: "(chdir|SetCurrentDirectoryW)" -> "$$SETCWD" use std::env; use std::io::ErrorKind; diff --git a/tests/run-pass/fs_with_isolation.rs b/tests/run-pass/fs_with_isolation.rs index a9e1e5094f..cd91cd9be3 100644 --- a/tests/run-pass/fs_with_isolation.rs +++ b/tests/run-pass/fs_with_isolation.rs @@ -1,6 +1,6 @@ // ignore-windows: File handling is not implemented yet // compile-flags: -Zmiri-isolation-error=warn-nobacktrace -// normalize-stderr-test "(stat(x)?)" -> "$$STAT" +// normalize-stderr-test: "(stat(x)?)" -> "$$STAT" #![feature(rustc_private)] diff --git a/tests/run-pass/linux-getrandom-without-isolation.rs b/tests/run-pass/linux-getrandom-without-isolation.rs index ce9ff8b6c3..e08d4466a7 100644 --- a/tests/run-pass/linux-getrandom-without-isolation.rs +++ b/tests/run-pass/linux-getrandom-without-isolation.rs @@ -1,7 +1,4 @@ -// Unfortunately, compiletest_rs does not support 'only-linux', -// so we need to ignore Windows and macOS instead. -// ignore-macos: Uses Linux-only APIs -// ignore-windows: Uses Linux-only APIs +// only-linux // compile-flags: -Zmiri-disable-isolation #![feature(rustc_private)] extern crate libc; diff --git a/tests/run-pass/linux-getrandom.rs b/tests/run-pass/linux-getrandom.rs index f582a282c5..762e754f81 100644 --- a/tests/run-pass/linux-getrandom.rs +++ b/tests/run-pass/linux-getrandom.rs @@ -1,7 +1,4 @@ -// Unfortunately, compiletest_rs does not support 'only-linux', -// so we need to ignore Windows and macOS instead. -// ignore-macos: Uses Linux-only APIs -// ignore-windows: Uses Linux-only APIs +// only-linux #![feature(rustc_private)] extern crate libc; diff --git a/tests/run-pass/panic/catch_panic.rs b/tests/run-pass/panic/catch_panic.rs index 63a3c9a476..80881948c0 100644 --- a/tests/run-pass/panic/catch_panic.rs +++ b/tests/run-pass/panic/catch_panic.rs @@ -1,5 +1,3 @@ -// normalize-stderr-test "[^ ]*core/[a-z_/]+.rs[0-9:]*" -> "$$LOC" -// normalize-stderr-test "catch_panic\.rs:[0-9]{2}" -> "catch_panic.rs:LL" // We test the `align_offset` panic below, make sure we test the interpreter impl and not the "real" one. // compile-flags: -Zmiri-symbolic-alignment-check #![feature(never_type)] diff --git a/tests/run-pass/panic/catch_panic.stderr b/tests/run-pass/panic/catch_panic.stderr index 0f43ab2520..36a7818d27 100644 --- a/tests/run-pass/panic/catch_panic.stderr +++ b/tests/run-pass/panic/catch_panic.stderr @@ -1,26 +1,26 @@ -thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:27 +thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:CC 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 +thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:LL:CC Caught panic message (String): Hello from panic: 1 -thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:LL:26 +thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:LL:CC Caught panic message (String): Hello from panic: 2 -thread 'main' panicked at 'Box', $DIR/catch_panic.rs:LL:27 +thread 'main' panicked at 'Box', $DIR/catch_panic.rs:LL:CC Failed to get caught panic message. -thread 'main' panicked at 'Hello from panic: core', $DIR/catch_panic.rs:LL:27 +thread 'main' panicked at 'Hello from panic: core', $DIR/catch_panic.rs:LL:CC Caught panic message (&str): Hello from panic: core -thread 'main' panicked at 'Hello from panic: 5', $DIR/catch_panic.rs:LL:26 +thread 'main' panicked at 'Hello from panic: 5', $DIR/catch_panic.rs:LL:CC Caught panic message (String): Hello from panic: 5 -thread 'main' panicked at 'Hello from panic: 6', $DIR/catch_panic.rs:LL:26 +thread 'main' panicked at 'Hello from panic: 6', $DIR/catch_panic.rs:LL:CC Caught panic message (String): Hello from panic: 6 -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4', $DIR/catch_panic.rs:LL:33 +thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4', $DIR/catch_panic.rs:LL:CC Caught panic message (String): index out of bounds: the len is 3 but the index is 4 -thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:LL:33 +thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:LL:CC Caught panic message (&str): attempt to divide by zero -thread 'main' panicked at 'align_offset: align is not a power-of-two', $LOC +thread 'main' panicked at 'align_offset: align is not a power-of-two', rustc_src/src/ptr/const_ptr.rs:LL:CC Caught panic message (&str): align_offset: align is not a power-of-two -thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:29 +thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:CC Caught panic message (&str): assertion failed: false -thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:29 +thread 'main' panicked at 'assertion failed: false', $DIR/catch_panic.rs:LL:CC Caught panic message (&str): assertion failed: false Success! diff --git a/tests/run-pass/panic/concurrent-panic.stderr b/tests/run-pass/panic/concurrent-panic.stderr index 1ee688c1d3..ae132c9ee3 100644 --- a/tests/run-pass/panic/concurrent-panic.stderr +++ b/tests/run-pass/panic/concurrent-panic.stderr @@ -2,11 +2,11 @@ warning: thread support is experimental and incomplete: weak memory effects are 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 +thread '' panicked at 'panic in thread 2', $DIR/concurrent-panic.rs:LL:CC 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 -thread '' panicked at 'panic in thread 1', $DIR/concurrent-panic.rs:42:13 +thread '' panicked at 'panic in thread 1', $DIR/concurrent-panic.rs:LL:CC Thread 1 has exited Thread 2 has exited diff --git a/tests/run-pass/panic/panic1.rs b/tests/run-pass/panic/panic1.rs deleted file mode 100644 index da300ecb59..0000000000 --- a/tests/run-pass/panic/panic1.rs +++ /dev/null @@ -1,9 +0,0 @@ -// rustc-env: RUST_BACKTRACE=1 -// compile-flags: -Zmiri-disable-isolation -// normalize-stderr-test "at .*/(rust[^/]*|checkout)/library/.*" -> "at RUSTLIB/$$FILE:LL:COL" -// normalize-stderr-test "::<.*>" -> "" - - -fn main() { - std::panic!("panicking from libstd"); -} diff --git a/tests/run-pass/stacked-borrows/generators-self-referential.rs b/tests/run-pass/stacked-borrows/generators-self-referential.rs index 01ce8a6141..b71912882d 100644 --- a/tests/run-pass/stacked-borrows/generators-self-referential.rs +++ b/tests/run-pass/stacked-borrows/generators-self-referential.rs @@ -13,7 +13,7 @@ fn firstn() -> impl Generator { let num = &mut num; yield *num; - *num += 1; //~ ERROR: borrow stack + *num += 1; // would fail here yield *num; *num += 1; diff --git a/tests/run-pass/track-alloc-1.stderr b/tests/run-pass/track-alloc-1.stderr index 3c5a55d986..be96b72983 100644 --- a/tests/run-pass/track-alloc-1.stderr +++ b/tests/run-pass/track-alloc-1.stderr @@ -1,5 +1,5 @@ note: tracking was triggered - | - = note: created allocation with id 1 - = note: (no span available) + | + = note: created allocation with id 1 + = note: (no span available) diff --git a/tests/run-pass/wtf8.rs b/tests/run-pass/wtf8.rs index 2b4da785f2..5a58150680 100644 --- a/tests/run-pass/wtf8.rs +++ b/tests/run-pass/wtf8.rs @@ -1,5 +1,4 @@ -// ignore-linux: tests Windows-only APIs -// ignore-macos: tests Windows-only APIs +// only-windows use std::os::windows::ffi::{OsStrExt, OsStringExt}; use std::ffi::{OsStr, OsString}; diff --git a/ui_test/Cargo.toml b/ui_test/Cargo.toml new file mode 100644 index 0000000000..66d35fdd22 --- /dev/null +++ b/ui_test/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "ui_test" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rustc_version = "0.4" +colored = "2" +regex = "1.5.5" +pretty_assertions = "1.2.1" +crossbeam = "0.8.1" +lazy_static = "1.4.0" diff --git a/ui_test/README.md b/ui_test/README.md new file mode 100644 index 0000000000..fdd94a7482 --- /dev/null +++ b/ui_test/README.md @@ -0,0 +1,30 @@ +A smaller version of compiletest-rs + +## Supported magic comment annotations + +Note that the space after `//`, when it is present, is *not* optional -- it must be exactly one. + +* `// ignore-XXX` avoids running the test on targets whose triple contains `XXX` + * `XXX` can also be one of `64bit`, `32bit` or `16bit` +* `// only-XXX` avoids running the test on targets whose triple **does not** contain `XXX` + * `XXX` can also be one of `64bit`, `32bit` or `16bit` +* `// stderr-per-bitwidth` produces one stderr file per bitwidth, as they may differ significantly sometimes +* `// error-pattern: XXX` make sure the stderr output contains `XXX` +* `//~ ERROR: XXX` make sure the stderr output contains `XXX` for an error in the line where this comment is written + * NOTE: it is not checked at present that it is actually in the line where the error occurred, or that it is truly an ERROR/WARNING/HELP/NOTE, but you should treat it as such until that becomes true. + * Also supports `HELP` or `WARN` for different kind of message + * if the all caps note is left out, any message is matched + * This checks the output *before* normalization, so you can check things that get normalized away, but need to + be careful not to accidentally have a pattern that differs between platforms. +* `// revisions: XXX YYY` runs the test once for each space separated name in the list + * emits one stderr file per revision + * `//~` comments can be restricted to specific revisions by adding the revision name before the `~` in square brackets: `//[XXX]~` +* `// compile-flags: XXX` appends `XXX` to the command line arguments passed to the rustc driver +* `// rustc-env: XXX=YYY` sets the env var `XXX` to `YYY` for the rustc driver execution. + * for Miri these env vars are used during compilation via rustc and during the emulation of the program +* `// normalize-stderr-test: "REGEX" -> "REPLACEMENT"` replaces all matches of `REGEX` in the stderr with `REPLACEMENT`. The replacement may specify `$1` and similar backreferences to paste captures. + +## Significant differences to compiletest-rs + +* `ignore-*` and `only-*` opereate solely on the triple, instead of supporting things like `macos` +* only `//~` comments can be individualized per revision diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs new file mode 100644 index 0000000000..14566d2fec --- /dev/null +++ b/ui_test/src/comments.rs @@ -0,0 +1,111 @@ +use std::path::Path; + +use regex::Regex; + +/// This crate supports various magic comments that get parsed as file-specific +/// configuration values. This struct parses them all in one go and then they +/// get processed by their respective use sites. +#[derive(Default)] +pub struct Comments { + /// List of revision names to execute. Can only be speicified once + pub revisions: Option>, + /// Don't run this test if any of these filters apply + pub ignore: Vec, + /// Only run this test if all of these filters apply + pub only: Vec, + /// Generate one .stderr file per bit width, by prepending with `.64bit` and similar + pub stderr_per_bitwidth: bool, + /// Additional flags to pass to the executable + pub compile_flags: Vec, + /// Additional env vars to set for the executable + pub env_vars: Vec<(String, String)>, + /// Normalizations to apply to the stderr output before emitting it to disk + pub normalize_stderr: Vec<(Regex, String)>, + /// An arbitrary pattern to look for in the stderr. + pub error_pattern: Option<(String, usize)>, + pub error_matches: Vec, +} + +pub struct ErrorMatch { + pub matched: String, + pub revision: Option, + pub definition_line: usize, +} + +impl Comments { + pub fn parse(path: &Path) -> Self { + let mut this = Self::default(); + let content = std::fs::read_to_string(path).unwrap(); + let error_pattern_regex = + Regex::new(r"//(\[(?P[^\]]+)\])?~[|^]*\s*(ERROR|HELP|WARN)?:?(?P.*)") + .unwrap(); + for (l, line) in content.lines().enumerate() { + if let Some(revisions) = line.strip_prefix("// revisions:") { + assert_eq!( + this.revisions, + None, + "{}:{l}, cannot specifiy revisions twice", + path.display() + ); + this.revisions = + Some(revisions.trim().split_whitespace().map(|s| s.to_string()).collect()); + } + if let Some(s) = line.strip_prefix("// ignore-") { + let s = s + .split_once(|c: char| c == ':' || c.is_whitespace()) + .map(|(s, _)| s) + .unwrap_or(s); + this.ignore.push(s.to_owned()); + } + if let Some(s) = line.strip_prefix("// only-") { + let s = s + .split_once(|c: char| c == ':' || c.is_whitespace()) + .map(|(s, _)| s) + .unwrap_or(s); + this.only.push(s.to_owned()); + } + if line.starts_with("// stderr-per-bitwidth") { + assert!( + !this.stderr_per_bitwidth, + "{}:{l}, cannot specifiy stderr-per-bitwidth twice", + path.display() + ); + this.stderr_per_bitwidth = true; + } + if let Some(s) = line.strip_prefix("// compile-flags:") { + this.compile_flags.extend(s.split_whitespace().map(|s| s.to_string())); + } + if let Some(s) = line.strip_prefix("// rustc-env:") { + for env in s.split_whitespace() { + if let Some((k, v)) = env.split_once('=') { + this.env_vars.push((k.to_string(), v.to_string())); + } + } + } + if let Some(s) = line.strip_prefix("// normalize-stderr-test:") { + let (from, to) = s.split_once("->").expect("normalize-stderr-test needs a `->`"); + let from = from.trim().trim_matches('"'); + let to = to.trim().trim_matches('"'); + let from = Regex::new(from).unwrap(); + this.normalize_stderr.push((from, to.to_string())); + } + if let Some(s) = line.strip_prefix("// error-pattern:") { + assert_eq!( + this.error_pattern, + None, + "{}:{l}, cannot specifiy error_pattern twice", + path.display() + ); + this.error_pattern = Some((s.trim().to_string(), l)); + } + if let Some(captures) = error_pattern_regex.captures(line) { + // FIXME: check that the error happens on the marked line + let matched = captures["text"].trim().to_string(); + + let revision = captures.name("revision").map(|rev| rev.as_str().to_string()); + this.error_matches.push(ErrorMatch { matched, revision, definition_line: l }); + } + } + this + } +} diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs new file mode 100644 index 0000000000..95ae3a51b2 --- /dev/null +++ b/ui_test/src/lib.rs @@ -0,0 +1,410 @@ +use std::fmt::Write; +use std::path::{Path, PathBuf}; +use std::process::{Command, ExitStatus}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::Mutex; + +use colored::*; +use comments::ErrorMatch; +use crossbeam::queue::SegQueue; +use regex::Regex; + +use crate::comments::Comments; + +mod comments; + +#[derive(Debug)] +pub struct Config { + /// Arguments passed to the binary that is executed. + pub args: Vec, + /// `None` to run on the host, otherwise a target triple + pub target: Option, + /// Filters applied to stderr output before processing it + pub stderr_filters: Filter, + /// Filters applied to stdout output before processing it + pub stdout_filters: Filter, + /// The folder in which to start searching for .rs files + pub root_dir: PathBuf, + pub mode: Mode, + pub program: PathBuf, + pub output_conflict_handling: OutputConflictHandling, +} + +#[derive(Debug)] +pub enum OutputConflictHandling { + /// The default: emit a diff of the expected/actual output. + Error, + /// Ignore mismatches in the stderr/stdout files. + Ignore, + /// Instead of erroring if the stderr/stdout differs from the expected + /// automatically replace it with the found output (after applying filters). + Bless, +} + +pub type Filter = Vec<(Regex, &'static str)>; + +pub fn run_tests(config: Config) { + eprintln!(" Compiler flags: {:?}", config.args); + + // Get the triple with which to run the tests + let target = config.target.clone().unwrap_or_else(|| config.get_host()); + + // A queue for files or folders to process + let todo = SegQueue::new(); + todo.push(config.root_dir.clone()); + + // Some statistics and failure reports. + let failures = Mutex::new(vec![]); + let succeeded = AtomicUsize::default(); + let skipped = AtomicUsize::default(); + + crossbeam::scope(|s| { + for _ in 0..std::thread::available_parallelism().unwrap().get() { + s.spawn(|_| { + while let Some(path) = todo.pop() { + // Collect everything inside directories + if path.is_dir() { + for entry in std::fs::read_dir(path).unwrap() { + todo.push(entry.unwrap().path()); + } + continue; + } + // Only look at .rs files + if !path.extension().map(|ext| ext == "rs").unwrap_or(false) { + continue; + } + let comments = Comments::parse(&path); + // Skip file if only/skip rules do (not) apply + if ignore_file(&comments, &target) { + skipped.fetch_add(1, Ordering::Relaxed); + eprintln!("{} .. {}", path.display(), "skipped".yellow()); + continue; + } + // Run the test for all revisions + for revision in + comments.revisions.clone().unwrap_or_else(|| vec![String::new()]) + { + let (m, errors) = run_test(&path, &config, &target, &revision, &comments); + + // Using `format` to prevent messages from threads from getting intermingled. + let mut msg = format!("{} ", path.display()); + if !revision.is_empty() { + write!(msg, "(revision `{revision}`) ").unwrap(); + } + write!(msg, " .. ").unwrap(); + if errors.is_empty() { + eprintln!("{msg}{}", "ok".green()); + succeeded.fetch_add(1, Ordering::Relaxed); + } else { + eprintln!("{msg}{}", "FAILED".red().bold()); + failures.lock().unwrap().push((path.clone(), m, revision, errors)); + } + } + } + }); + } + }) + .unwrap(); + + // Print all errors in a single thread to show reliable output + let failures = failures.into_inner().unwrap(); + let succeeded = succeeded.load(Ordering::Relaxed); + let skipped = skipped.load(Ordering::Relaxed); + if !failures.is_empty() { + for (path, miri, revision, errors) in &failures { + eprintln!(); + eprint!("{}", path.display().to_string().underline()); + if !revision.is_empty() { + eprint!(" (revision `{}`)", revision); + } + eprint!("{}", " FAILED".red()); + eprintln!(); + eprintln!("command: {:?}", miri); + eprintln!(); + let mut dump_stderr = None; + for error in errors { + match error { + Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"), + Error::PatternNotFound { stderr, pattern, definition_line } => { + eprintln!("`{pattern}` {} in stderr output", "not found".red()); + eprintln!( + "expected because of pattern here: {}:{definition_line}", + path.display() + ); + dump_stderr = Some(stderr.clone()) + } + Error::NoPatternsFound => + eprintln!("{}", "no error patterns found in failure test".red()), + Error::PatternFoundInPassTest => + eprintln!("{}", "error pattern found in success test".red()), + Error::OutputDiffers { path, actual, expected } => { + dump_stderr = None; + eprintln!("actual output differed from expected {}", path.display()); + eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual)); + eprintln!() + } + } + eprintln!(); + } + if let Some(stderr) = dump_stderr { + eprintln!("actual stderr:"); + eprintln!("{}", stderr); + eprintln!(); + } + } + eprintln!( + "{} tests failed, {} tests passed, {} skipped", + failures.len().to_string().red().bold(), + succeeded.to_string().green(), + skipped.to_string().yellow() + ); + std::process::exit(1); + } + eprintln!(); + eprintln!( + "{} tests passed, {} skipped", + succeeded.to_string().green(), + skipped.to_string().yellow() + ); +} + +#[derive(Debug)] +enum Error { + /// Got an invalid exit status for the given mode. + ExitStatus(Mode, ExitStatus), + PatternNotFound { + stderr: String, + pattern: String, + definition_line: usize, + }, + /// A ui test checking for failure does not have any failure patterns + NoPatternsFound, + /// A ui test checking for success has failure patterns + PatternFoundInPassTest, + /// Stderr/Stdout differed from the `.stderr`/`.stdout` file present. + OutputDiffers { + path: PathBuf, + actual: String, + expected: String, + }, +} + +type Errors = Vec; + +fn run_test( + path: &Path, + config: &Config, + target: &str, + revision: &str, + comments: &Comments, +) -> (Command, Errors) { + // Run miri + let mut miri = Command::new(&config.program); + miri.args(config.args.iter()); + miri.arg(path); + if !revision.is_empty() { + miri.arg(format!("--cfg={revision}")); + } + for arg in &comments.compile_flags { + miri.arg(arg); + } + for (k, v) in &comments.env_vars { + miri.env(k, v); + } + let output = miri.output().expect("could not execute miri"); + let mut errors = config.mode.ok(output.status); + // Check output files (if any) + let revised = |extension: &str| { + if revision.is_empty() { + extension.to_string() + } else { + format!("{}.{}", revision, extension) + } + }; + // Check output files against actual output + check_output( + &output.stderr, + path, + &mut errors, + revised("stderr"), + target, + &config.stderr_filters, + &config, + comments, + ); + check_output( + &output.stdout, + path, + &mut errors, + revised("stdout"), + target, + &config.stdout_filters, + &config, + comments, + ); + // Check error annotations in the source against output + check_annotations(&output.stderr, &mut errors, config, revision, comments); + (miri, errors) +} + +fn check_annotations( + unnormalized_stderr: &[u8], + errors: &mut Errors, + config: &Config, + revision: &str, + comments: &Comments, +) { + let unnormalized_stderr = std::str::from_utf8(unnormalized_stderr).unwrap(); + let mut found_annotation = false; + if let Some((ref error_pattern, definition_line)) = comments.error_pattern { + if !unnormalized_stderr.contains(error_pattern) { + errors.push(Error::PatternNotFound { + stderr: unnormalized_stderr.to_string(), + pattern: error_pattern.to_string(), + definition_line, + }); + } + found_annotation = true; + } + for &ErrorMatch { ref matched, revision: ref rev, definition_line } in &comments.error_matches { + // FIXME: check that the error happens on the marked line + + if let Some(rev) = rev { + if rev != revision { + continue; + } + } + + if !unnormalized_stderr.contains(matched) { + errors.push(Error::PatternNotFound { + stderr: unnormalized_stderr.to_string(), + pattern: matched.to_string(), + definition_line, + }); + } + found_annotation = true; + } + match (config.mode, found_annotation) { + (Mode::Pass, true) | (Mode::Panic, true) => errors.push(Error::PatternFoundInPassTest), + (Mode::Fail, false) => errors.push(Error::NoPatternsFound), + _ => {} + }; +} + +fn check_output( + output: &[u8], + path: &Path, + errors: &mut Errors, + kind: String, + target: &str, + filters: &Filter, + config: &Config, + comments: &Comments, +) { + let output = std::str::from_utf8(&output).unwrap(); + let output = normalize(path, output, filters, comments); + let path = output_path(path, comments, kind, target); + match config.output_conflict_handling { + OutputConflictHandling::Bless => + if output.is_empty() { + let _ = std::fs::remove_file(path); + } else { + std::fs::write(path, &output).unwrap(); + }, + OutputConflictHandling::Error => { + let expected_output = std::fs::read_to_string(&path).unwrap_or_default(); + if output != expected_output { + errors.push(Error::OutputDiffers { + path, + actual: output, + expected: expected_output, + }); + } + } + OutputConflictHandling::Ignore => {} + } +} + +fn output_path(path: &Path, comments: &Comments, kind: String, target: &str) -> PathBuf { + if comments.stderr_per_bitwidth { + return path.with_extension(format!("{}.{kind}", get_pointer_width(target))); + } + path.with_extension(kind) +} + +fn ignore_file(comments: &Comments, target: &str) -> bool { + for s in &comments.ignore { + if target.contains(s) { + return true; + } + if get_pointer_width(target) == s { + return true; + } + } + for s in &comments.only { + if !target.contains(s) { + return true; + } + if get_pointer_width(target) != s { + return true; + } + } + false +} + +// Taken 1:1 from compiletest-rs +fn get_pointer_width(triple: &str) -> &'static str { + if (triple.contains("64") && !triple.ends_with("gnux32") && !triple.ends_with("gnu_ilp32")) + || triple.starts_with("s390x") + { + "64bit" + } else if triple.starts_with("avr") { + "16bit" + } else { + "32bit" + } +} + +fn normalize(path: &Path, text: &str, filters: &Filter, comments: &Comments) -> String { + // Useless paths + let mut text = text.replace(&path.parent().unwrap().display().to_string(), "$DIR"); + if let Some(lib_path) = option_env!("RUSTC_LIB_PATH") { + text = text.replace(lib_path, "RUSTLIB"); + } + + for (regex, replacement) in filters.iter() { + text = regex.replace_all(&text, *replacement).to_string(); + } + + for (from, to) in &comments.normalize_stderr { + text = from.replace_all(&text, to).to_string(); + } + text +} + +impl Config { + fn get_host(&self) -> String { + rustc_version::VersionMeta::for_command(std::process::Command::new(&self.program)) + .expect("failed to parse rustc version info") + .host + } +} + +#[derive(Copy, Clone, Debug)] +pub enum Mode { + // The test passes a full execution of the rustc driver + Pass, + // The rustc driver panicked + Panic, + // The rustc driver emitted an error + Fail, +} + +impl Mode { + fn ok(self, status: ExitStatus) -> Errors { + match (status.code().unwrap(), self) { + (1, Mode::Fail) | (101, Mode::Panic) | (0, Mode::Pass) => vec![], + _ => vec![Error::ExitStatus(self, status)], + } + } +}