From 32c2ed7b263e649236561219ae2f781e8fa40c19 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 31 Jul 2023 08:04:29 +0000 Subject: Bump ui test crate --- src/tools/miri/Cargo.lock | 100 +++++++++++++++++++++++++++++++++--- src/tools/miri/Cargo.toml | 2 +- src/tools/miri/tests/compiletest.rs | 63 ++++++++--------------- 3 files changed, 115 insertions(+), 50 deletions(-) diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock index f253d71e50d..f0a145767b3 100644 --- a/src/tools/miri/Cargo.lock +++ b/src/tools/miri/Cargo.lock @@ -26,6 +26,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anyhow" version = "1.0.71" @@ -159,6 +168,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "comma" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" + +[[package]] +name = "console" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", +] + [[package]] name = "crossbeam-channel" version = "0.5.8" @@ -189,10 +217,16 @@ dependencies = [ ] [[package]] -name = "diff" -version = "0.1.13" +name = "distance" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240" + +[[package]] +name = "encode_unicode" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "env_logger" @@ -282,6 +316,19 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indicatif" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + [[package]] name = "instant" version = "0.1.12" @@ -463,6 +510,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.30.3" @@ -484,6 +537,15 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +[[package]] +name = "pad" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ad9b889f1b12e0b9ee24db044b5129150d5eada288edc800f789928dc8c0e3" +dependencies = [ + "unicode-width", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -524,12 +586,28 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +[[package]] +name = "portable-atomic" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" + [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettydiff" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff1fec61082821f8236cf6c0c14e8172b62ce8a72a0eedc30d3b247bb68dc11" +dependencies = [ + "ansi_term", + "pad", +] + [[package]] name = "proc-macro2" version = "1.0.66" @@ -859,18 +937,22 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.11.7" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c" +checksum = "33d15b71b50d95aeb687f68289543b9cabdbec7afc277176ce9dfcf192c7035d" dependencies = [ + "anyhow", "bstr", "cargo-platform", "cargo_metadata", "color-eyre", "colored", + "comma", "crossbeam-channel", - "diff", + "distance", + "indicatif", "lazy_static", + "prettydiff", "regex", "rustc_version", "rustfix", @@ -885,6 +967,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + [[package]] name = "valuable" version = "0.1.0" diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 2ae6f922e3a..86ba460bb86 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -36,7 +36,7 @@ libloading = "0.7" [dev-dependencies] colored = "2" -ui_test = "0.11.7" +ui_test = "0.14" rustc_version = "0.4" # Features chosen to match those required by env_logger, to avoid rebuilds regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 78dd3df01ec..f3ea43c0413 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -97,7 +97,7 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> output_conflict_handling, out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"), edition: Some("2021".into()), - ..Config::rustc(path.into()) + ..Config::rustc(path) }; let use_std = env::var_os("MIRI_NO_STD").is_none(); @@ -123,49 +123,19 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R let config = test_config(target, path, mode, with_dependencies); // Handle command-line arguments. - let mut after_dashdash = false; - let mut quiet = false; - let filters = std::env::args() - .skip(1) - .filter(|arg| { - if after_dashdash { - // Just propagate everything. - return true; - } - match &**arg { - "--quiet" => { - quiet = true; - false - } - "--" => { - after_dashdash = true; - false - } - s if s.starts_with('-') => { - panic!("unknown compiletest flag `{s}`"); - } - _ => true, - } - }) - .collect::>(); + let args = ui_test::Args::test(); + let quiet = args.quiet; eprintln!(" Compiler: {}", config.program.display()); ui_test::run_tests_generic( - config, + vec![config], + std::thread::available_parallelism().unwrap(), + args, // The files we're actually interested in (all `.rs` files). - |path| { - path.extension().is_some_and(|ext| ext == "rs") - && (filters.is_empty() - || filters.iter().any(|f| path.display().to_string().contains(f))) - }, + ui_test::default_file_filter, // This could be used to overwrite the `Config` on a per-test basis. - |_, _| None, + |_, _| {}, ( - if quiet { - Box::::default() - as Box - } else { - Box::new(status_emitter::Text) - }, + if quiet { status_emitter::Text::quiet() } else { status_emitter::Text::verbose() }, status_emitter::Gha:: { name: format!("{mode:?} {path} ({target})"), }, @@ -269,11 +239,16 @@ fn main() -> Result<()> { ui(Mode::Pass, "tests/pass", &target, WithoutDependencies)?; ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies)?; ui(Mode::Panic, "tests/panic", &target, WithDependencies)?; - ui(Mode::Fail { require_patterns: true }, "tests/fail", &target, WithDependencies)?; + ui( + Mode::Fail { require_patterns: true, rustfix: false }, + "tests/fail", + &target, + WithDependencies, + )?; if cfg!(target_os = "linux") { ui(Mode::Pass, "tests/extern-so/pass", &target, WithoutDependencies)?; ui( - Mode::Fail { require_patterns: true }, + Mode::Fail { require_patterns: true, rustfix: false }, "tests/extern-so/fail", &target, WithoutDependencies, @@ -285,11 +260,13 @@ fn main() -> Result<()> { fn run_dep_mode(target: String, mut args: impl Iterator) -> Result<()> { let path = args.next().expect("./miri run-dep must be followed by a file name"); - let mut config = test_config(&target, "", Mode::Yolo, /* with dependencies */ true); + let mut config = + test_config(&target, "", Mode::Yolo { rustfix: false }, /* with dependencies */ true); config.program.args.clear(); // We want to give the user full control over flags - config.build_dependencies_and_link_them()?; + let dep_args = config.build_dependencies()?; let mut cmd = config.program.build(&config.out_dir); + cmd.args(dep_args); cmd.arg(path); -- cgit 1.4.1-3-g733a5 From c69e0c2a9bb652ea425da3546159a19255f11381 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 3 Aug 2023 18:45:04 +0000 Subject: Move `fail` tests that need dependencies into their own folder, so that wasm tests don't build dependencies --- src/tools/miri/tests/compiletest.rs | 6 +++ .../libc_pthread_create_main_terminate.rs | 19 +++++++++ .../libc_pthread_create_main_terminate.stderr | 6 +++ .../libc_pthread_create_too_few_args.rs | 22 ++++++++++ .../libc_pthread_create_too_few_args.stderr | 14 +++++++ .../libc_pthread_create_too_many_args.rs | 22 ++++++++++ .../libc_pthread_create_too_many_args.stderr | 14 +++++++ .../concurrency/libc_pthread_join_detached.rs | 20 +++++++++ .../concurrency/libc_pthread_join_detached.stderr | 15 +++++++ .../concurrency/libc_pthread_join_joined.rs | 20 +++++++++ .../concurrency/libc_pthread_join_joined.stderr | 15 +++++++ .../fail-dep/concurrency/libc_pthread_join_main.rs | 16 ++++++++ .../concurrency/libc_pthread_join_main.stderr | 15 +++++++ .../concurrency/libc_pthread_join_multiple.rs | 29 +++++++++++++ .../concurrency/libc_pthread_join_multiple.stderr | 15 +++++++ .../fail-dep/concurrency/libc_pthread_join_self.rs | 18 +++++++++ .../concurrency/libc_pthread_join_self.stderr | 15 +++++++ .../fail-dep/concurrency/unwind_top_of_stack.rs | 29 +++++++++++++ .../concurrency/unwind_top_of_stack.stderr | 21 ++++++++++ .../miri/tests/fail-dep/shims/fs/close_stdout.rs | 10 +++++ .../tests/fail-dep/shims/fs/close_stdout.stderr | 14 +++++++ .../miri/tests/fail-dep/shims/fs/isolated_stdin.rs | 9 +++++ .../tests/fail-dep/shims/fs/isolated_stdin.stderr | 15 +++++++ .../fail-dep/shims/fs/mkstemp_immutable_arg.rs | 11 +++++ .../fail-dep/shims/fs/mkstemp_immutable_arg.stderr | 20 +++++++++ .../tests/fail-dep/shims/fs/read_from_stdout.rs | 10 +++++ .../fail-dep/shims/fs/read_from_stdout.stderr | 14 +++++++ .../shims/fs/unix_open_missing_required_mode.rs | 12 ++++++ .../fs/unix_open_missing_required_mode.stderr | 20 +++++++++ .../miri/tests/fail-dep/shims/fs/write_to_stdin.rs | 9 +++++ .../tests/fail-dep/shims/fs/write_to_stdin.stderr | 14 +++++++ src/tools/miri/tests/fail-dep/shims/memchr_null.rs | 10 +++++ .../miri/tests/fail-dep/shims/memchr_null.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcmp_null.rs | 10 +++++ .../miri/tests/fail-dep/shims/memcmp_null.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs | 13 ++++++ .../miri/tests/fail-dep/shims/memcmp_zero.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs | 12 ++++++ .../miri/tests/fail-dep/shims/memcpy_zero.stderr | 15 +++++++ .../miri/tests/fail-dep/shims/memrchr_null.rs | 11 +++++ .../miri/tests/fail-dep/shims/memrchr_null.stderr | 15 +++++++ .../tests/fail-dep/shims/mmap_invalid_dealloc.rs | 18 +++++++++ .../fail-dep/shims/mmap_invalid_dealloc.stderr | 15 +++++++ .../tests/fail-dep/shims/mmap_use_after_munmap.rs | 19 +++++++++ .../fail-dep/shims/mmap_use_after_munmap.stderr | 47 ++++++++++++++++++++++ src/tools/miri/tests/fail-dep/shims/munmap.rs | 22 ++++++++++ src/tools/miri/tests/fail-dep/shims/munmap.stderr | 39 ++++++++++++++++++ .../miri/tests/fail-dep/shims/munmap_partial.rs | 18 +++++++++ .../tests/fail-dep/shims/munmap_partial.stderr | 29 +++++++++++++ .../shims/sync/libc_pthread_cond_double_destroy.rs | 20 +++++++++ .../sync/libc_pthread_cond_double_destroy.stderr | 15 +++++++ .../sync/libc_pthread_condattr_double_destroy.rs | 17 ++++++++ .../libc_pthread_condattr_double_destroy.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_NULL_deadlock.rs | 12 ++++++ .../sync/libc_pthread_mutex_NULL_deadlock.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_deadlock.rs | 28 +++++++++++++ .../shims/sync/libc_pthread_mutex_deadlock.stderr | 12 ++++++ .../sync/libc_pthread_mutex_default_deadlock.rs | 13 ++++++ .../libc_pthread_mutex_default_deadlock.stderr | 15 +++++++ .../sync/libc_pthread_mutex_destroy_locked.rs | 15 +++++++ .../sync/libc_pthread_mutex_destroy_locked.stderr | 15 +++++++ .../sync/libc_pthread_mutex_double_destroy.rs | 21 ++++++++++ .../sync/libc_pthread_mutex_double_destroy.stderr | 15 +++++++ .../sync/libc_pthread_mutex_normal_deadlock.rs | 15 +++++++ .../sync/libc_pthread_mutex_normal_deadlock.stderr | 12 ++++++ .../libc_pthread_mutex_normal_unlock_unlocked.rs | 16 ++++++++ ...ibc_pthread_mutex_normal_unlock_unlocked.stderr | 15 +++++++ .../shims/sync/libc_pthread_mutex_wrong_owner.rs | 28 +++++++++++++ .../sync/libc_pthread_mutex_wrong_owner.stderr | 15 +++++++ .../sync/libc_pthread_mutexattr_double_destroy.rs | 17 ++++++++ .../libc_pthread_mutexattr_double_destroy.stderr | 15 +++++++ .../libc_pthread_rwlock_destroy_read_locked.rs | 9 +++++ .../libc_pthread_rwlock_destroy_read_locked.stderr | 15 +++++++ .../libc_pthread_rwlock_destroy_write_locked.rs | 9 +++++ ...libc_pthread_rwlock_destroy_write_locked.stderr | 15 +++++++ .../sync/libc_pthread_rwlock_double_destroy.rs | 14 +++++++ .../sync/libc_pthread_rwlock_double_destroy.stderr | 15 +++++++ ...ead_rwlock_read_write_deadlock_single_thread.rs | 9 +++++ ...rwlock_read_write_deadlock_single_thread.stderr | 12 ++++++ .../sync/libc_pthread_rwlock_read_wrong_owner.rs | 28 +++++++++++++ .../libc_pthread_rwlock_read_wrong_owner.stderr | 15 +++++++ .../sync/libc_pthread_rwlock_unlock_unlocked.rs | 8 ++++ .../libc_pthread_rwlock_unlock_unlocked.stderr | 15 +++++++ .../libc_pthread_rwlock_write_read_deadlock.rs | 28 +++++++++++++ .../libc_pthread_rwlock_write_read_deadlock.stderr | 12 ++++++ ...ead_rwlock_write_read_deadlock_single_thread.rs | 9 +++++ ...rwlock_write_read_deadlock_single_thread.stderr | 12 ++++++ .../libc_pthread_rwlock_write_write_deadlock.rs | 28 +++++++++++++ ...libc_pthread_rwlock_write_write_deadlock.stderr | 12 ++++++ ...ad_rwlock_write_write_deadlock_single_thread.rs | 9 +++++ ...wlock_write_write_deadlock_single_thread.stderr | 12 ++++++ .../sync/libc_pthread_rwlock_write_wrong_owner.rs | 28 +++++++++++++ .../libc_pthread_rwlock_write_wrong_owner.stderr | 15 +++++++ src/tools/miri/tests/fail-dep/tokio/sleep.rs | 14 +++++++ src/tools/miri/tests/fail-dep/tokio/sleep.stderr | 15 +++++++ .../fail-dep/unsupported_incomplete_function.rs | 11 +++++ .../unsupported_incomplete_function.stderr | 14 +++++++ .../libc_pthread_create_main_terminate.rs | 19 --------- .../libc_pthread_create_main_terminate.stderr | 6 --- .../libc_pthread_create_too_few_args.rs | 22 ---------- .../libc_pthread_create_too_few_args.stderr | 14 ------- .../libc_pthread_create_too_many_args.rs | 22 ---------- .../libc_pthread_create_too_many_args.stderr | 14 ------- .../fail/concurrency/libc_pthread_join_detached.rs | 20 --------- .../concurrency/libc_pthread_join_detached.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_joined.rs | 20 --------- .../concurrency/libc_pthread_join_joined.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_main.rs | 16 -------- .../fail/concurrency/libc_pthread_join_main.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_multiple.rs | 29 ------------- .../concurrency/libc_pthread_join_multiple.stderr | 15 ------- .../fail/concurrency/libc_pthread_join_self.rs | 18 --------- .../fail/concurrency/libc_pthread_join_self.stderr | 15 ------- .../tests/fail/concurrency/unwind_top_of_stack.rs | 29 ------------- .../fail/concurrency/unwind_top_of_stack.stderr | 21 ---------- src/tools/miri/tests/fail/shims/fs/close_stdout.rs | 10 ----- .../miri/tests/fail/shims/fs/close_stdout.stderr | 14 ------- .../miri/tests/fail/shims/fs/isolated_stdin.rs | 9 ----- .../miri/tests/fail/shims/fs/isolated_stdin.stderr | 15 ------- .../tests/fail/shims/fs/mkstemp_immutable_arg.rs | 11 ----- .../fail/shims/fs/mkstemp_immutable_arg.stderr | 20 --------- .../miri/tests/fail/shims/fs/read_from_stdout.rs | 10 ----- .../tests/fail/shims/fs/read_from_stdout.stderr | 14 ------- .../shims/fs/unix_open_missing_required_mode.rs | 12 ------ .../fs/unix_open_missing_required_mode.stderr | 20 --------- .../miri/tests/fail/shims/fs/write_to_stdin.rs | 9 ----- .../miri/tests/fail/shims/fs/write_to_stdin.stderr | 14 ------- src/tools/miri/tests/fail/shims/memchr_null.rs | 10 ----- src/tools/miri/tests/fail/shims/memchr_null.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcmp_null.rs | 10 ----- src/tools/miri/tests/fail/shims/memcmp_null.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcmp_zero.rs | 13 ------ src/tools/miri/tests/fail/shims/memcmp_zero.stderr | 15 ------- src/tools/miri/tests/fail/shims/memcpy_zero.rs | 12 ------ src/tools/miri/tests/fail/shims/memcpy_zero.stderr | 15 ------- src/tools/miri/tests/fail/shims/memrchr_null.rs | 11 ----- .../miri/tests/fail/shims/memrchr_null.stderr | 15 ------- .../miri/tests/fail/shims/mmap_invalid_dealloc.rs | 18 --------- .../tests/fail/shims/mmap_invalid_dealloc.stderr | 15 ------- .../miri/tests/fail/shims/mmap_use_after_munmap.rs | 19 --------- .../tests/fail/shims/mmap_use_after_munmap.stderr | 47 ---------------------- src/tools/miri/tests/fail/shims/munmap.rs | 22 ---------- src/tools/miri/tests/fail/shims/munmap.stderr | 39 ------------------ src/tools/miri/tests/fail/shims/munmap_partial.rs | 18 --------- .../miri/tests/fail/shims/munmap_partial.stderr | 29 ------------- .../shims/sync/libc_pthread_cond_double_destroy.rs | 20 --------- .../sync/libc_pthread_cond_double_destroy.stderr | 15 ------- .../sync/libc_pthread_condattr_double_destroy.rs | 17 -------- .../libc_pthread_condattr_double_destroy.stderr | 15 ------- .../shims/sync/libc_pthread_mutex_NULL_deadlock.rs | 12 ------ .../sync/libc_pthread_mutex_NULL_deadlock.stderr | 15 ------- .../fail/shims/sync/libc_pthread_mutex_deadlock.rs | 28 ------------- .../shims/sync/libc_pthread_mutex_deadlock.stderr | 12 ------ .../sync/libc_pthread_mutex_default_deadlock.rs | 13 ------ .../libc_pthread_mutex_default_deadlock.stderr | 15 ------- .../sync/libc_pthread_mutex_destroy_locked.rs | 15 ------- .../sync/libc_pthread_mutex_destroy_locked.stderr | 15 ------- .../sync/libc_pthread_mutex_double_destroy.rs | 21 ---------- .../sync/libc_pthread_mutex_double_destroy.stderr | 15 ------- .../sync/libc_pthread_mutex_normal_deadlock.rs | 15 ------- .../sync/libc_pthread_mutex_normal_deadlock.stderr | 12 ------ .../libc_pthread_mutex_normal_unlock_unlocked.rs | 16 -------- ...ibc_pthread_mutex_normal_unlock_unlocked.stderr | 15 ------- .../shims/sync/libc_pthread_mutex_wrong_owner.rs | 28 ------------- .../sync/libc_pthread_mutex_wrong_owner.stderr | 15 ------- .../sync/libc_pthread_mutexattr_double_destroy.rs | 17 -------- .../libc_pthread_mutexattr_double_destroy.stderr | 15 ------- .../libc_pthread_rwlock_destroy_read_locked.rs | 9 ----- .../libc_pthread_rwlock_destroy_read_locked.stderr | 15 ------- .../libc_pthread_rwlock_destroy_write_locked.rs | 9 ----- ...libc_pthread_rwlock_destroy_write_locked.stderr | 15 ------- .../sync/libc_pthread_rwlock_double_destroy.rs | 14 ------- .../sync/libc_pthread_rwlock_double_destroy.stderr | 15 ------- ...ead_rwlock_read_write_deadlock_single_thread.rs | 9 ----- ...rwlock_read_write_deadlock_single_thread.stderr | 12 ------ .../sync/libc_pthread_rwlock_read_wrong_owner.rs | 28 ------------- .../libc_pthread_rwlock_read_wrong_owner.stderr | 15 ------- .../sync/libc_pthread_rwlock_unlock_unlocked.rs | 8 ---- .../libc_pthread_rwlock_unlock_unlocked.stderr | 15 ------- .../libc_pthread_rwlock_write_read_deadlock.rs | 28 ------------- .../libc_pthread_rwlock_write_read_deadlock.stderr | 12 ------ ...ead_rwlock_write_read_deadlock_single_thread.rs | 9 ----- ...rwlock_write_read_deadlock_single_thread.stderr | 12 ------ .../libc_pthread_rwlock_write_write_deadlock.rs | 28 ------------- ...libc_pthread_rwlock_write_write_deadlock.stderr | 12 ------ ...ad_rwlock_write_write_deadlock_single_thread.rs | 9 ----- ...wlock_write_write_deadlock_single_thread.stderr | 12 ------ .../sync/libc_pthread_rwlock_write_wrong_owner.rs | 28 ------------- .../libc_pthread_rwlock_write_wrong_owner.stderr | 15 ------- src/tools/miri/tests/fail/tokio/sleep.rs | 14 ------- src/tools/miri/tests/fail/tokio/sleep.stderr | 15 ------- .../tests/fail/unsupported_incomplete_function.rs | 11 ----- .../fail/unsupported_incomplete_function.stderr | 14 ------- 193 files changed, 1571 insertions(+), 1565 deletions(-) create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr create mode 100644 src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs create mode 100644 src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memchr_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memchr_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/memrchr_null.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap_partial.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs create mode 100644 src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr create mode 100644 src/tools/miri/tests/fail-dep/tokio/sleep.rs create mode 100644 src/tools/miri/tests/fail-dep/tokio/sleep.stderr create mode 100644 src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs create mode 100644 src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr delete mode 100644 src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs delete mode 100644 src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/close_stdout.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/close_stdout.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr delete mode 100644 src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs delete mode 100644 src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memchr_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memchr_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_zero.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcmp_zero.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memcpy_zero.rs delete mode 100644 src/tools/miri/tests/fail/shims/memcpy_zero.stderr delete mode 100644 src/tools/miri/tests/fail/shims/memrchr_null.rs delete mode 100644 src/tools/miri/tests/fail/shims/memrchr_null.stderr delete mode 100644 src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs delete mode 100644 src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr delete mode 100644 src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs delete mode 100644 src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr delete mode 100644 src/tools/miri/tests/fail/shims/munmap.rs delete mode 100644 src/tools/miri/tests/fail/shims/munmap.stderr delete mode 100644 src/tools/miri/tests/fail/shims/munmap_partial.rs delete mode 100644 src/tools/miri/tests/fail/shims/munmap_partial.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs delete mode 100644 src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr delete mode 100644 src/tools/miri/tests/fail/tokio/sleep.rs delete mode 100644 src/tools/miri/tests/fail/tokio/sleep.stderr delete mode 100644 src/tools/miri/tests/fail/unsupported_incomplete_function.rs delete mode 100644 src/tools/miri/tests/fail/unsupported_incomplete_function.stderr diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index f3ea43c0413..d84f943a6f9 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -243,6 +243,12 @@ fn main() -> Result<()> { Mode::Fail { require_patterns: true, rustfix: false }, "tests/fail", &target, + WithoutDependencies, + )?; + ui( + Mode::Fail { require_patterns: true, rustfix: false }, + "tests/fail-dep", + &target, WithDependencies, )?; if cfg!(target_os = "linux") { diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs new file mode 100644 index 00000000000..7e6f490bb3d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.rs @@ -0,0 +1,19 @@ +//@ignore-target-windows: No libc on Windows +//@error-in-other-file: the main thread terminated without waiting for all remaining threads + +// Check that we terminate the program when the main thread terminates. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + loop {} +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr new file mode 100644 index 00000000000..c5093c0e601 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_main_terminate.stderr @@ -0,0 +1,6 @@ +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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs new file mode 100644 index 00000000000..e1d3704af7c --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.rs @@ -0,0 +1,22 @@ +//@ignore-target-windows: No libc on Windows + +//! The thread function must have exactly one argument. + +use std::{mem, ptr}; + +extern "C" fn thread_start() -> *mut libc::c_void { + panic!() //~ ERROR: callee has fewer arguments than expected +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr new file mode 100644 index 00000000000..c2de4afd68f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr @@ -0,0 +1,14 @@ +error: Undefined Behavior: callee has fewer arguments than expected + --> $DIR/libc_pthread_create_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: BACKTRACE: + = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs new file mode 100644 index 00000000000..7408634db52 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.rs @@ -0,0 +1,22 @@ +//@ignore-target-windows: No libc on Windows + +//! The thread function must have exactly one argument. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void, _x: i32) -> *mut libc::c_void { + panic!() //~ ERROR: callee has more arguments than expected +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr new file mode 100644 index 00000000000..85ae930d439 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr @@ -0,0 +1,14 @@ +error: Undefined Behavior: callee has more arguments than expected + --> $DIR/libc_pthread_create_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: BACKTRACE: + = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC + = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs new file mode 100644 index 00000000000..0b810dc8c72 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +// Joining a detached thread is undefined behavior. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_detach(native), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr new file mode 100644 index 00000000000..763e0d3665d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join a detached 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 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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs new file mode 100644 index 00000000000..04ca4bbb3f6 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +// Joining an already joined thread is undefined behavior. + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr new file mode 100644 index 00000000000..a3253e2ef93 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join an 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 an 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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs new file mode 100644 index 00000000000..75765182163 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.rs @@ -0,0 +1,16 @@ +//@ignore-target-windows: No libc on Windows + +// Joining the main thread is undefined behavior. + +use std::{ptr, thread}; + +fn main() { + let thread_id: libc::pthread_t = unsafe { libc::pthread_self() }; + let handle = thread::spawn(move || { + unsafe { + assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread + } + }); + thread::yield_now(); + handle.join().unwrap(); +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr new file mode 100644 index 00000000000..09e14d46a96 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join a detached 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 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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs new file mode 100644 index 00000000000..966f416eeac --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.rs @@ -0,0 +1,29 @@ +//@ignore-target-windows: No libc on Windows + +// Joining the same thread from multiple threads is undefined behavior. + +use std::thread; +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + // Yield the thread several times so that other threads can join it. + thread::yield_now(); + thread::yield_now(); + ptr::null_mut() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + let mut native_copy: libc::pthread_t = mem::zeroed(); + ptr::copy_nonoverlapping(&native, &mut native_copy, 1); + let handle = thread::spawn(move || { + assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread + }); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + handle.join().unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr new file mode 100644 index 00000000000..db5d7bfd5da --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: trying to join an 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 an 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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs new file mode 100644 index 00000000000..0c25c690f37 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.rs @@ -0,0 +1,18 @@ +//@ignore-target-windows: No libc on Windows +// We are making scheduler assumptions here. +//@compile-flags: -Zmiri-preemption-rate=0 + +// Joining itself is undefined behavior. + +use std::{ptr, thread}; + +fn main() { + let handle = thread::spawn(|| { + unsafe { + let native: libc::pthread_t = libc::pthread_self(); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join itself + } + }); + thread::yield_now(); + handle.join().unwrap(); +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr new file mode 100644 index 00000000000..8db4a83f9ce --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_self.stderr @@ -0,0 +1,15 @@ +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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs new file mode 100644 index 00000000000..4704cfed039 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs @@ -0,0 +1,29 @@ +//@ignore-target-windows: No libc on Windows + +//@compile-flags: -Zmiri-disable-abi-check + +//! Unwinding past the top frame of a stack is Undefined Behavior. + +#![feature(c_unwind)] + +use std::{mem, ptr}; + +extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + //~^ ERROR: unwinding past the topmost frame of the stack + panic!() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + // Cast to avoid inserting abort-on-unwind. + let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = + thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +} diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr new file mode 100644 index 00000000000..fccd3fbbc9d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr @@ -0,0 +1,21 @@ +WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed. +If you have a use-case for it, please file an issue. +thread '' panicked at $DIR/unwind_top_of_stack.rs:LL:CC: +explicit panic +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 | | +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: BACKTRACE: + = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs new file mode 100644 index 00000000000..09da8509af4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +// FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032) + +fn main() { + unsafe { + libc::close(1); //~ ERROR: cannot close stdout + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr new file mode 100644 index 00000000000..02f1eee97fc --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/close_stdout.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: cannot close stdout + --> $DIR/close_stdout.rs:LL:CC + | +LL | libc::close(1); + | ^^^^^^^^^^^^^^ cannot close 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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs new file mode 100644 index 00000000000..a45f805696d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let mut bytes = [0u8; 512]; + unsafe { + libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: `read` from stdin not available when isolation is enabled + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr b/src/tools/miri/tests/fail-dep/shims/fs/isolated_stdin.stderr new file mode 100644 index 00000000000..ed826147e3b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs new file mode 100644 index 00000000000..ba9f404d7c9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.rs @@ -0,0 +1,11 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +fn main() { + test_mkstemp_immutable_arg(); +} + +fn test_mkstemp_immutable_arg() { + let s: *mut libc::c_char = b"fooXXXXXX\0" as *const _ as *mut _; + let _fd = unsafe { libc::mkstemp(s) }; //~ ERROR: Undefined Behavior: writing to alloc1 which is read-only +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr new file mode 100644 index 00000000000..35ff1926b06 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/mkstemp_immutable_arg.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: writing to ALLOC which is read-only + --> $DIR/mkstemp_immutable_arg.rs:LL:CC + | +LL | let _fd = unsafe { libc::mkstemp(s) }; + | ^^^^^^^^^^^^^^^^ 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: BACKTRACE: + = note: inside `test_mkstemp_immutable_arg` at $DIR/mkstemp_immutable_arg.rs:LL:CC +note: inside `main` + --> $DIR/mkstemp_immutable_arg.rs:LL:CC + | +LL | test_mkstemp_immutable_arg(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs new file mode 100644 index 00000000000..073fca4712e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.rs @@ -0,0 +1,10 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let mut bytes = [0u8; 512]; + unsafe { + libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: cannot read from stdout + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr b/src/tools/miri/tests/fail-dep/shims/fs/read_from_stdout.stderr new file mode 100644 index 00000000000..bcece7ad4e5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs new file mode 100644 index 00000000000..ae231d4be66 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-disable-isolation + +fn main() { + test_file_open_missing_needed_mode(); +} + +fn test_file_open_missing_needed_mode() { + let name = b"missing_arg.txt\0"; + let name_ptr = name.as_ptr().cast::(); + let _fd = unsafe { libc::open(name_ptr, libc::O_CREAT) }; //~ ERROR: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr b/src/tools/miri/tests/fail-dep/shims/fs/unix_open_missing_required_mode.stderr new file mode 100644 index 00000000000..5a8e7352c76 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = note: inside `test_file_open_missing_needed_mode` at $DIR/unix_open_missing_required_mode.rs:LL:CC +note: inside `main` + --> $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/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs new file mode 100644 index 00000000000..d039ad718d3 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() -> std::io::Result<()> { + let bytes = b"hello"; + unsafe { + libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); //~ ERROR: cannot write to stdin + } + Ok(()) +} diff --git a/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr b/src/tools/miri/tests/fail-dep/shims/fs/write_to_stdin.stderr new file mode 100644 index 00000000000..d4a38e1ca96 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/memchr_null.rs b/src/tools/miri/tests/fail-dep/shims/memchr_null.rs new file mode 100644 index 00000000000..6bc7af7e6bf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memchr_null.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memchr(ptr::null(), 0, 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr b/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr new file mode 100644 index 00000000000..54b58f22c6c --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memchr_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memchr_null.rs:LL:CC + | +LL | libc::memchr(ptr::null(), 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/memchr_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/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs b/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs new file mode 100644 index 00000000000..a4e0034c40b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_null.rs @@ -0,0 +1,10 @@ +//@ignore-target-windows: No libc on Windows + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr b/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr new file mode 100644 index 00000000000..8b2882fc243 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memcmp_null.rs:LL:CC + | +LL | libc::memcmp(ptr::null(), ptr::null(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/memcmp_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/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs new file mode 100644 index 00000000000..f2ddc200563 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.rs @@ -0,0 +1,13 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-permissive-provenance + +// C says that passing "invalid" pointers is UB for all string functions. +// It is unclear whether `(int*)42` is "invalid", but there is no actually +// a `char` living at that address, so arguably it cannot be a valid pointer. +// Hence this is UB. +fn main() { + let ptr = 42 as *const u8; + unsafe { + libc::memcmp(ptr.cast(), ptr.cast(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr new file mode 100644 index 00000000000..e21b9b06008 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcmp_zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) + --> $DIR/memcmp_zero.rs:LL:CC + | +LL | libc::memcmp(ptr.cast(), ptr.cast(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/memcmp_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/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs new file mode 100644 index 00000000000..5283fea4cb9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +//@compile-flags: -Zmiri-permissive-provenance +// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`. + +fn main() { + let from = 42 as *const u8; + let to = 23 as *mut u8; + unsafe { + to.copy_from(from, 0); // this is fine + libc::memcpy(to.cast(), from.cast(), 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr new file mode 100644 index 00000000000..7c1c3fe20c4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memcpy_zero.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) + --> $DIR/memcpy_zero.rs:LL:CC + | +LL | libc::memcpy(to.cast(), from.cast(), 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/memcpy_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/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs b/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs new file mode 100644 index 00000000000..b6707d558d8 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memrchr_null.rs @@ -0,0 +1,11 @@ +//@ignore-target-windows: No libc on Windows +//@ignore-target-apple: No `memrchr` on some apple targets + +use std::ptr; + +// null is explicitly called out as UB in the C docs. +fn main() { + unsafe { + libc::memrchr(ptr::null(), 0, 0); //~ERROR: dangling + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr b/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr new file mode 100644 index 00000000000..cc11ba89f8f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/memrchr_null.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + --> $DIR/memrchr_null.rs:LL:CC + | +LL | libc::memrchr(ptr::null(), 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/memrchr_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/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs new file mode 100644 index 00000000000..70f7a6a7cef --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.rs @@ -0,0 +1,18 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + 4096, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::free(ptr); //~ ERROR: which is mmap memory, using C heap deallocation operation + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr new file mode 100644 index 00000000000..54e0cd5275d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_invalid_dealloc.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: deallocating ALLOC, which is mmap memory, using C heap deallocation operation + --> $DIR/mmap_invalid_dealloc.rs:LL:CC + | +LL | libc::free(ptr); + | ^^^^^^^^^^^^^^^ deallocating ALLOC, which is mmap memory, using C 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: BACKTRACE: + = note: inside `main` at $DIR/mmap_invalid_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 + diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs new file mode 100644 index 00000000000..c97b013ba5a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.rs @@ -0,0 +1,19 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + 4096, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::munmap(ptr, 4096); + let _x = *(ptr as *mut u8); //~ ERROR: has been freed + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr new file mode 100644 index 00000000000..44e122330bc --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/mmap_use_after_munmap.stderr @@ -0,0 +1,47 @@ +warning: integer-to-pointer cast + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | libc::munmap(ptr, 4096); + | ^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC + +error: Undefined Behavior: dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | let _x = *(ptr as *mut u8); + | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling + | + = 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 +help: ALLOC was allocated here: + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | let ptr = libc::mmap( + | ___________________^ +LL | | std::ptr::null_mut(), +LL | | 4096, +LL | | libc::PROT_READ | libc::PROT_WRITE, +... | +LL | | 0, +LL | | ); + | |_________^ +help: ALLOC was deallocated here: + --> $DIR/mmap_use_after_munmap.rs:LL:CC + | +LL | libc::munmap(ptr, 4096); + | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: BACKTRACE (of the first span): + = note: inside `main` at $DIR/mmap_use_after_munmap.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/src/tools/miri/tests/fail-dep/shims/munmap.rs b/src/tools/miri/tests/fail-dep/shims/munmap.rs new file mode 100644 index 00000000000..453437a06cf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap.rs @@ -0,0 +1,22 @@ +//@compile-flags: -Zmiri-disable-isolation +//@ignore-target-windows: No libc on Windows + +#![feature(rustc_private)] +#![feature(strict_provenance)] + +use std::ptr; + +fn main() { + // Linux specifies that it is not an error if the specified range does not contain any pages. + // But we simply do not support such calls. This test checks that we report this as + // unsupported, not Undefined Behavior. + let res = unsafe { + libc::munmap( + //~^ ERROR: unsupported operation + // Some high address we surely have not allocated anything at + ptr::invalid_mut(1 << 30), + 4096, + ) + }; + assert_eq!(res, 0); +} diff --git a/src/tools/miri/tests/fail-dep/shims/munmap.stderr b/src/tools/miri/tests/fail-dep/shims/munmap.stderr new file mode 100644 index 00000000000..cb47769c063 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap.stderr @@ -0,0 +1,39 @@ +warning: integer-to-pointer cast + --> $DIR/munmap.rs:LL:CC + | +LL | / libc::munmap( +LL | | +LL | | // Some high address we surely have not allocated anything at +LL | | ptr::invalid_mut(1 << 30), +LL | | 4096, +LL | | ) + | |_________^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap.rs:LL:CC + +error: unsupported operation: Miri only supports munmap on memory allocated directly by mmap + --> $DIR/munmap.rs:LL:CC + | +LL | / libc::munmap( +LL | | +LL | | // Some high address we surely have not allocated anything at +LL | | ptr::invalid_mut(1 << 30), +LL | | 4096, +LL | | ) + | |_________^ Miri only supports munmap on memory allocated directly by mmap + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/munmap.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/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs b/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs new file mode 100644 index 00000000000..938850ee286 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap_partial.rs @@ -0,0 +1,18 @@ +//! Our mmap/munmap support is a thin wrapper over Interpcx::allocate_ptr. Since the underlying +//! layer has much more UB than munmap does, we need to be sure we throw an unsupported error here. +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let ptr = libc::mmap( + std::ptr::null_mut(), + page_size::get() * 2, + libc::PROT_READ | libc::PROT_WRITE, + libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, + -1, + 0, + ); + libc::munmap(ptr, 1); + //~^ ERROR: unsupported operation + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr b/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr new file mode 100644 index 00000000000..9a084c50437 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/munmap_partial.stderr @@ -0,0 +1,29 @@ +warning: integer-to-pointer cast + --> $DIR/munmap_partial.rs:LL:CC + | +LL | libc::munmap(ptr, 1); + | ^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast + | + = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, + = help: which means that Miri might miss pointer bugs in this program. + = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. + = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. + = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. + = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. + = note: BACKTRACE: + = note: inside `main` at $DIR/munmap_partial.rs:LL:CC + +error: unsupported operation: Miri only supports munmap calls that exactly unmap a region previously returned by mmap + --> $DIR/munmap_partial.rs:LL:CC + | +LL | libc::munmap(ptr, 1); + | ^^^^^^^^^^^^^^^^^^^^ Miri only supports munmap calls that exactly unmap a region previously returned by mmap + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/munmap_partial.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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs new file mode 100644 index 00000000000..94ca3496ed9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.rs @@ -0,0 +1,20 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_cond twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + libc::pthread_condattr_init(attr.as_mut_ptr()); + + let mut cond = MaybeUninit::::uninit(); + + libc::pthread_cond_init(cond.as_mut_ptr(), attr.as_ptr()); + + libc::pthread_cond_destroy(cond.as_mut_ptr()); + + libc::pthread_cond_destroy(cond.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_cond_double_destroy.stderr new file mode 100644 index 00000000000..ecfedf75370 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs new file mode 100644 index 00000000000..13e639a867d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.rs @@ -0,0 +1,17 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_condattr twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + + libc::pthread_condattr_init(attr.as_mut_ptr()); + + libc::pthread_condattr_destroy(attr.as_mut_ptr()); + + libc::pthread_condattr_destroy(attr.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_condattr_double_destroy.stderr new file mode 100644 index 00000000000..f39d909adbd --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs new file mode 100644 index 00000000000..8b251073383 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.rs @@ -0,0 +1,12 @@ +//@ignore-target-windows: No libc on Windows +// +// Check that if we pass NULL attribute, then we get the default mutex type. + +fn main() { + unsafe { + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, std::ptr::null() as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr new file mode 100644 index 00000000000..4a138e6f8a2 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs new file mode 100644 index 00000000000..6c3cb738e29 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct Mutex(UnsafeCell); + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +fn new_lock() -> Arc { + Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr new file mode 100644 index 00000000000..599655a8692 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr @@ -0,0 +1,12 @@ +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 + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs new file mode 100644 index 00000000000..f443768819f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.rs @@ -0,0 +1,13 @@ +//@ignore-target-windows: No libc on Windows +// +// Check that if we do not set the mutex type, it is the default. + +fn main() { + unsafe { + let mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_default_deadlock.stderr new file mode 100644 index 00000000000..8aea3f5c693 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs new file mode 100644 index 00000000000..ec3965c7574 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.rs @@ -0,0 +1,15 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR: destroyed a locked mutex + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_destroy_locked.stderr new file mode 100644 index 00000000000..a8ab948116e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs new file mode 100644 index 00000000000..622c3eaeae3 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.rs @@ -0,0 +1,21 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_mutex twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + + let mut attr = MaybeUninit::::uninit(); + libc::pthread_mutexattr_init(attr.as_mut_ptr()); + + let mut mutex = MaybeUninit::::uninit(); + + libc::pthread_mutex_init(mutex.as_mut_ptr(), attr.as_ptr()); + + libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + + libc::pthread_mutex_destroy(mutex.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_double_destroy.stderr new file mode 100644 index 00000000000..9620fdbd18b --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs new file mode 100644 index 00000000000..5ea09fa5aac --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.rs @@ -0,0 +1,15 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: deadlock: the evaluated program deadlocked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr new file mode 100644 index 00000000000..b7877d3aa39 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs new file mode 100644 index 00000000000..8ce7542edb8 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs @@ -0,0 +1,16 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + unsafe { + let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); + assert_eq!( + libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), + 0, + ); + let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); + assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); + assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); + assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0); + libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR: was not locked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr new file mode 100644 index 00000000000..754137b85b9 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs new file mode 100644 index 00000000000..b56775252e4 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct Mutex(UnsafeCell); + +unsafe impl Send for Mutex {} +unsafe impl Sync for Mutex {} + +fn new_lock() -> Arc { + Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked a default mutex that was not locked by the current thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr new file mode 100644 index 00000000000..aa81b06fc80 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr @@ -0,0 +1,15 @@ +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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs new file mode 100644 index 00000000000..474a277516d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.rs @@ -0,0 +1,17 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity + +fn main() { + unsafe { + use core::mem::MaybeUninit; + let mut attr = MaybeUninit::::uninit(); + + libc::pthread_mutexattr_init(attr.as_mut_ptr()); + + libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + + libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_mutexattr_double_destroy.stderr new file mode 100644 index 00000000000..82949047d2a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs new file mode 100644 index 00000000000..603580ff58a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); + libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr new file mode 100644 index 00000000000..be73e7f1e2a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs new file mode 100644 index 00000000000..ae44f22d146 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr new file mode 100644 index 00000000000..bc2713a5ffb --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs new file mode 100644 index 00000000000..800986f7506 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.rs @@ -0,0 +1,14 @@ +//@ignore-target-windows: No libc on Windows + +/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity + +fn main() { + unsafe { + let mut lock = libc::PTHREAD_RWLOCK_INITIALIZER; + + libc::pthread_rwlock_destroy(&mut lock); + + libc::pthread_rwlock_destroy(&mut lock); + //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_double_destroy.stderr new file mode 100644 index 00000000000..5004f84358d --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs new file mode 100644 index 00000000000..782c95b6d2e --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); + libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr new file mode 100644 index 00000000000..075c8f0ef52 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs new file mode 100644 index 00000000000..1b498ad8fcd --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr new file mode 100644 index 00000000000..7dfa27b43d0 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr @@ -0,0 +1,15 @@ +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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs new file mode 100644 index 00000000000..05f7e7a06c5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs @@ -0,0 +1,8 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + libc::pthread_rwlock_unlock(rw.get()); //~ ERROR: was not locked + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr new file mode 100644 index 00000000000..1c25ac2c048 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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: BACKTRACE: + = 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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs new file mode 100644 index 00000000000..201844615e1 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr new file mode 100644 index 00000000000..333fb1afb91 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr @@ -0,0 +1,12 @@ +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 + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs new file mode 100644 index 00000000000..538f14ef89f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr new file mode 100644 index 00000000000..caab19a782f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs new file mode 100644 index 00000000000..b1d7e0492e5 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr new file mode 100644 index 00000000000..93bede54fcf --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr @@ -0,0 +1,12 @@ +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 + diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs new file mode 100644 index 00000000000..2c963d36510 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs @@ -0,0 +1,9 @@ +//@ignore-target-windows: No libc on Windows + +fn main() { + let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); + unsafe { + assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); + libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr new file mode 100644 index 00000000000..30f5f447c71 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/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/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs new file mode 100644 index 00000000000..dd099474d8f --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs @@ -0,0 +1,28 @@ +//@ignore-target-windows: No libc on Windows + +use std::cell::UnsafeCell; +use std::sync::Arc; +use std::thread; + +struct RwLock(UnsafeCell); + +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} + +fn new_lock() -> Arc { + Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) +} + +fn main() { + unsafe { + let lock = new_lock(); + assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); + + let lock_copy = lock.clone(); + thread::spawn(move || { + assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread + }) + .join() + .unwrap(); + } +} diff --git a/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr new file mode 100644 index 00000000000..5bf402c775a --- /dev/null +++ b/src/tools/miri/tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr @@ -0,0 +1,15 @@ +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: BACKTRACE: + = 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 + diff --git a/src/tools/miri/tests/fail-dep/tokio/sleep.rs b/src/tools/miri/tests/fail-dep/tokio/sleep.rs new file mode 100644 index 00000000000..d96d778e6ca --- /dev/null +++ b/src/tools/miri/tests/fail-dep/tokio/sleep.rs @@ -0,0 +1,14 @@ +//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full +//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86 +//@error-in-other-file: returning ready events from epoll_wait is not yet implemented +//@normalize-stderr-test: " += note:.*\n" -> "" + +use tokio::time::{sleep, Duration, Instant}; + +#[tokio::main] +async fn main() { + let start = Instant::now(); + sleep(Duration::from_secs(1)).await; + let time_elapsed = &start.elapsed().as_millis(); + assert!((1000..1100).contains(time_elapsed), "{}", time_elapsed); +} diff --git a/src/tools/miri/tests/fail-dep/tokio/sleep.stderr b/src/tools/miri/tests/fail-dep/tokio/sleep.stderr new file mode 100644 index 00000000000..ac2a984ed51 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/tokio/sleep.stderr @@ -0,0 +1,15 @@ +error: unsupported operation: returning ready events from epoll_wait is not yet implemented + --> CARGO_REGISTRY/.../epoll.rs:LL:CC + | +LL | / syscall!(epoll_wait( +LL | | self.ep, +LL | | events.as_mut_ptr(), +LL | | events.capacity() as i32, +LL | | timeout, +LL | | )) + | |__________^ returning ready events from epoll_wait is not yet implemented + | + = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs new file mode 100644 index 00000000000..6ef842c9ccb --- /dev/null +++ b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.rs @@ -0,0 +1,11 @@ +//! `signal()` is special on Linux and macOS that it's only supported within libstd. +//! The implementation is not complete enough to permit user code to call it. +//@ignore-target-windows: No libc on Windows +//@normalize-stderr-test: "OS `.*`" -> "$$OS" + +fn main() { + unsafe { + libc::signal(libc::SIGPIPE, libc::SIG_IGN); + //~^ ERROR: unsupported operation: can't call foreign function `signal` + } +} diff --git a/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr new file mode 100644 index 00000000000..ec2bba61172 --- /dev/null +++ b/src/tools/miri/tests/fail-dep/unsupported_incomplete_function.stderr @@ -0,0 +1,14 @@ +error: unsupported operation: can't call foreign function `signal` on $OS + --> $DIR/unsupported_incomplete_function.rs:LL:CC + | +LL | libc::signal(libc::SIGPIPE, libc::SIG_IGN); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `signal` on $OS + | + = 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: BACKTRACE: + = note: inside `main` at $DIR/unsupported_incomplete_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/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs deleted file mode 100644 index 7e6f490bb3d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@error-in-other-file: the main thread terminated without waiting for all remaining threads - -// Check that we terminate the program when the main thread terminates. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - loop {} -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr deleted file mode 100644 index c5093c0e601..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_main_terminate.stderr +++ /dev/null @@ -1,6 +0,0 @@ -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 - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs deleted file mode 100644 index e1d3704af7c..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//! The thread function must have exactly one argument. - -use std::{mem, ptr}; - -extern "C" fn thread_start() -> *mut libc::c_void { - panic!() //~ ERROR: callee has fewer arguments than expected -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr deleted file mode 100644 index c2de4afd68f..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_few_args.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: Undefined Behavior: callee has fewer arguments than expected - --> $DIR/libc_pthread_create_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: BACKTRACE: - = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs deleted file mode 100644 index 7408634db52..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//! The thread function must have exactly one argument. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void, _x: i32) -> *mut libc::c_void { - panic!() //~ ERROR: callee has more arguments than expected -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr deleted file mode 100644 index 85ae930d439..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_create_too_many_args.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: Undefined Behavior: callee has more arguments than expected - --> $DIR/libc_pthread_create_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: BACKTRACE: - = note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs deleted file mode 100644 index 0b810dc8c72..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining a detached thread is undefined behavior. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_detach(native), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr deleted file mode 100644 index 763e0d3665d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_detached.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join a detached 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 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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs deleted file mode 100644 index 04ca4bbb3f6..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining an already joined thread is undefined behavior. - -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr deleted file mode 100644 index a3253e2ef93..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_joined.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join an 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 an 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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs deleted file mode 100644 index 75765182163..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining the main thread is undefined behavior. - -use std::{ptr, thread}; - -fn main() { - let thread_id: libc::pthread_t = unsafe { libc::pthread_self() }; - let handle = thread::spawn(move || { - unsafe { - assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join a detached thread - } - }); - thread::yield_now(); - handle.join().unwrap(); -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr deleted file mode 100644 index 09e14d46a96..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_main.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join a detached 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 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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs deleted file mode 100644 index 966f416eeac..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -// Joining the same thread from multiple threads is undefined behavior. - -use std::thread; -use std::{mem, ptr}; - -extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - // Yield the thread several times so that other threads can join it. - thread::yield_now(); - thread::yield_now(); - ptr::null_mut() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - let mut native_copy: libc::pthread_t = mem::zeroed(); - ptr::copy_nonoverlapping(&native, &mut native_copy, 1); - let handle = thread::spawn(move || { - assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join an already joined thread - }); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - handle.join().unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr deleted file mode 100644 index db5d7bfd5da..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_multiple.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: trying to join an 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 an 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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs deleted file mode 100644 index 0c25c690f37..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// We are making scheduler assumptions here. -//@compile-flags: -Zmiri-preemption-rate=0 - -// Joining itself is undefined behavior. - -use std::{ptr, thread}; - -fn main() { - let handle = thread::spawn(|| { - unsafe { - let native: libc::pthread_t = libc::pthread_self(); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); //~ ERROR: Undefined Behavior: trying to join itself - } - }); - thread::yield_now(); - handle.join().unwrap(); -} diff --git a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr b/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr deleted file mode 100644 index 8db4a83f9ce..00000000000 --- a/src/tools/miri/tests/fail/concurrency/libc_pthread_join_self.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs b/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs deleted file mode 100644 index 4704cfed039..00000000000 --- a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -//@compile-flags: -Zmiri-disable-abi-check - -//! Unwinding past the top frame of a stack is Undefined Behavior. - -#![feature(c_unwind)] - -use std::{mem, ptr}; - -extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { - //~^ ERROR: unwinding past the topmost frame of the stack - panic!() -} - -fn main() { - unsafe { - let mut native: libc::pthread_t = mem::zeroed(); - let attr: libc::pthread_attr_t = mem::zeroed(); - // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. - // Cast to avoid inserting abort-on-unwind. - let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = - thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = - mem::transmute(thread_start); - assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); - assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); - } -} diff --git a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr b/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr deleted file mode 100644 index fccd3fbbc9d..00000000000 --- a/src/tools/miri/tests/fail/concurrency/unwind_top_of_stack.stderr +++ /dev/null @@ -1,21 +0,0 @@ -WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed. -If you have a use-case for it, please file an issue. -thread '' panicked at $DIR/unwind_top_of_stack.rs:LL:CC: -explicit panic -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 | | -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: BACKTRACE: - = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/close_stdout.rs b/src/tools/miri/tests/fail/shims/fs/close_stdout.rs deleted file mode 100644 index 09da8509af4..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/close_stdout.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -// FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032) - -fn main() { - unsafe { - libc::close(1); //~ ERROR: cannot close stdout - } -} diff --git a/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr b/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr deleted file mode 100644 index 02f1eee97fc..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/close_stdout.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: cannot close stdout - --> $DIR/close_stdout.rs:LL:CC - | -LL | libc::close(1); - | ^^^^^^^^^^^^^^ cannot close 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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs b/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs deleted file mode 100644 index a45f805696d..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let mut bytes = [0u8; 512]; - unsafe { - libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: `read` from stdin not available when isolation is enabled - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr b/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr deleted file mode 100644 index ed826147e3b..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/isolated_stdin.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs b/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs deleted file mode 100644 index ba9f404d7c9..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -fn main() { - test_mkstemp_immutable_arg(); -} - -fn test_mkstemp_immutable_arg() { - let s: *mut libc::c_char = b"fooXXXXXX\0" as *const _ as *mut _; - let _fd = unsafe { libc::mkstemp(s) }; //~ ERROR: Undefined Behavior: writing to alloc1 which is read-only -} diff --git a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr b/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr deleted file mode 100644 index 35ff1926b06..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/mkstemp_immutable_arg.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: Undefined Behavior: writing to ALLOC which is read-only - --> $DIR/mkstemp_immutable_arg.rs:LL:CC - | -LL | let _fd = unsafe { libc::mkstemp(s) }; - | ^^^^^^^^^^^^^^^^ 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: BACKTRACE: - = note: inside `test_mkstemp_immutable_arg` at $DIR/mkstemp_immutable_arg.rs:LL:CC -note: inside `main` - --> $DIR/mkstemp_immutable_arg.rs:LL:CC - | -LL | test_mkstemp_immutable_arg(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs b/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs deleted file mode 100644 index 073fca4712e..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let mut bytes = [0u8; 512]; - unsafe { - libc::read(1, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: cannot read from stdout - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr b/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr deleted file mode 100644 index bcece7ad4e5..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/read_from_stdout.stderr +++ /dev/null @@ -1,14 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs b/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs deleted file mode 100644 index ae231d4be66..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-disable-isolation - -fn main() { - test_file_open_missing_needed_mode(); -} - -fn test_file_open_missing_needed_mode() { - let name = b"missing_arg.txt\0"; - let name_ptr = name.as_ptr().cast::(); - let _fd = unsafe { libc::open(name_ptr, libc::O_CREAT) }; //~ ERROR: Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected at least 3 -} diff --git a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr b/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr deleted file mode 100644 index 5a8e7352c76..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/unix_open_missing_required_mode.stderr +++ /dev/null @@ -1,20 +0,0 @@ -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: BACKTRACE: - = note: inside `test_file_open_missing_needed_mode` at $DIR/unix_open_missing_required_mode.rs:LL:CC -note: inside `main` - --> $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/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs b/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs deleted file mode 100644 index d039ad718d3..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() -> std::io::Result<()> { - let bytes = b"hello"; - unsafe { - libc::write(0, bytes.as_ptr() as *const libc::c_void, 5); //~ ERROR: cannot write to stdin - } - Ok(()) -} diff --git a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr b/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr deleted file mode 100644 index d4a38e1ca96..00000000000 --- a/src/tools/miri/tests/fail/shims/fs/write_to_stdin.stderr +++ /dev/null @@ -1,14 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/memchr_null.rs b/src/tools/miri/tests/fail/shims/memchr_null.rs deleted file mode 100644 index 6bc7af7e6bf..00000000000 --- a/src/tools/miri/tests/fail/shims/memchr_null.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memchr(ptr::null(), 0, 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memchr_null.stderr b/src/tools/miri/tests/fail/shims/memchr_null.stderr deleted file mode 100644 index 54b58f22c6c..00000000000 --- a/src/tools/miri/tests/fail/shims/memchr_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memchr_null.rs:LL:CC - | -LL | libc::memchr(ptr::null(), 0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/memchr_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/src/tools/miri/tests/fail/shims/memcmp_null.rs b/src/tools/miri/tests/fail/shims/memcmp_null.rs deleted file mode 100644 index a4e0034c40b..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_null.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcmp_null.stderr b/src/tools/miri/tests/fail/shims/memcmp_null.stderr deleted file mode 100644 index 8b2882fc243..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memcmp_null.rs:LL:CC - | -LL | libc::memcmp(ptr::null(), ptr::null(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/memcmp_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/src/tools/miri/tests/fail/shims/memcmp_zero.rs b/src/tools/miri/tests/fail/shims/memcmp_zero.rs deleted file mode 100644 index f2ddc200563..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_zero.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-permissive-provenance - -// C says that passing "invalid" pointers is UB for all string functions. -// It is unclear whether `(int*)42` is "invalid", but there is no actually -// a `char` living at that address, so arguably it cannot be a valid pointer. -// Hence this is UB. -fn main() { - let ptr = 42 as *const u8; - unsafe { - libc::memcmp(ptr.cast(), ptr.cast(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcmp_zero.stderr b/src/tools/miri/tests/fail/shims/memcmp_zero.stderr deleted file mode 100644 index e21b9b06008..00000000000 --- a/src/tools/miri/tests/fail/shims/memcmp_zero.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) - --> $DIR/memcmp_zero.rs:LL:CC - | -LL | libc::memcmp(ptr.cast(), ptr.cast(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance) - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/memcmp_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/src/tools/miri/tests/fail/shims/memcpy_zero.rs b/src/tools/miri/tests/fail/shims/memcpy_zero.rs deleted file mode 100644 index 5283fea4cb9..00000000000 --- a/src/tools/miri/tests/fail/shims/memcpy_zero.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@compile-flags: -Zmiri-permissive-provenance -// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`. - -fn main() { - let from = 42 as *const u8; - let to = 23 as *mut u8; - unsafe { - to.copy_from(from, 0); // this is fine - libc::memcpy(to.cast(), from.cast(), 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memcpy_zero.stderr b/src/tools/miri/tests/fail/shims/memcpy_zero.stderr deleted file mode 100644 index 7c1c3fe20c4..00000000000 --- a/src/tools/miri/tests/fail/shims/memcpy_zero.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) - --> $DIR/memcpy_zero.rs:LL:CC - | -LL | libc::memcpy(to.cast(), from.cast(), 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance) - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/memcpy_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/src/tools/miri/tests/fail/shims/memrchr_null.rs b/src/tools/miri/tests/fail/shims/memrchr_null.rs deleted file mode 100644 index b6707d558d8..00000000000 --- a/src/tools/miri/tests/fail/shims/memrchr_null.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ignore-target-windows: No libc on Windows -//@ignore-target-apple: No `memrchr` on some apple targets - -use std::ptr; - -// null is explicitly called out as UB in the C docs. -fn main() { - unsafe { - libc::memrchr(ptr::null(), 0, 0); //~ERROR: dangling - } -} diff --git a/src/tools/miri/tests/fail/shims/memrchr_null.stderr b/src/tools/miri/tests/fail/shims/memrchr_null.stderr deleted file mode 100644 index cc11ba89f8f..00000000000 --- a/src/tools/miri/tests/fail/shims/memrchr_null.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - --> $DIR/memrchr_null.rs:LL:CC - | -LL | libc::memrchr(ptr::null(), 0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance) - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/memrchr_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/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs b/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs deleted file mode 100644 index 70f7a6a7cef..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - 4096, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::free(ptr); //~ ERROR: which is mmap memory, using C heap deallocation operation - } -} diff --git a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr b/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr deleted file mode 100644 index 54e0cd5275d..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_invalid_dealloc.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: Undefined Behavior: deallocating ALLOC, which is mmap memory, using C heap deallocation operation - --> $DIR/mmap_invalid_dealloc.rs:LL:CC - | -LL | libc::free(ptr); - | ^^^^^^^^^^^^^^^ deallocating ALLOC, which is mmap memory, using C 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: BACKTRACE: - = note: inside `main` at $DIR/mmap_invalid_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 - diff --git a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs b/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs deleted file mode 100644 index c97b013ba5a..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - 4096, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::munmap(ptr, 4096); - let _x = *(ptr as *mut u8); //~ ERROR: has been freed - } -} diff --git a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr b/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr deleted file mode 100644 index 44e122330bc..00000000000 --- a/src/tools/miri/tests/fail/shims/mmap_use_after_munmap.stderr +++ /dev/null @@ -1,47 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | libc::munmap(ptr, 4096); - | ^^^^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/mmap_use_after_munmap.rs:LL:CC - -error: Undefined Behavior: dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | let _x = *(ptr as *mut u8); - | ^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has been freed, so this pointer is dangling - | - = 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 -help: ALLOC was allocated here: - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | let ptr = libc::mmap( - | ___________________^ -LL | | std::ptr::null_mut(), -LL | | 4096, -LL | | libc::PROT_READ | libc::PROT_WRITE, -... | -LL | | 0, -LL | | ); - | |_________^ -help: ALLOC was deallocated here: - --> $DIR/mmap_use_after_munmap.rs:LL:CC - | -LL | libc::munmap(ptr, 4096); - | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: BACKTRACE (of the first span): - = note: inside `main` at $DIR/mmap_use_after_munmap.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/src/tools/miri/tests/fail/shims/munmap.rs b/src/tools/miri/tests/fail/shims/munmap.rs deleted file mode 100644 index 453437a06cf..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@compile-flags: -Zmiri-disable-isolation -//@ignore-target-windows: No libc on Windows - -#![feature(rustc_private)] -#![feature(strict_provenance)] - -use std::ptr; - -fn main() { - // Linux specifies that it is not an error if the specified range does not contain any pages. - // But we simply do not support such calls. This test checks that we report this as - // unsupported, not Undefined Behavior. - let res = unsafe { - libc::munmap( - //~^ ERROR: unsupported operation - // Some high address we surely have not allocated anything at - ptr::invalid_mut(1 << 30), - 4096, - ) - }; - assert_eq!(res, 0); -} diff --git a/src/tools/miri/tests/fail/shims/munmap.stderr b/src/tools/miri/tests/fail/shims/munmap.stderr deleted file mode 100644 index cb47769c063..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap.stderr +++ /dev/null @@ -1,39 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/munmap.rs:LL:CC - | -LL | / libc::munmap( -LL | | -LL | | // Some high address we surely have not allocated anything at -LL | | ptr::invalid_mut(1 << 30), -LL | | 4096, -LL | | ) - | |_________^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap.rs:LL:CC - -error: unsupported operation: Miri only supports munmap on memory allocated directly by mmap - --> $DIR/munmap.rs:LL:CC - | -LL | / libc::munmap( -LL | | -LL | | // Some high address we surely have not allocated anything at -LL | | ptr::invalid_mut(1 << 30), -LL | | 4096, -LL | | ) - | |_________^ Miri only supports munmap on memory allocated directly by mmap - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/munmap.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/src/tools/miri/tests/fail/shims/munmap_partial.rs b/src/tools/miri/tests/fail/shims/munmap_partial.rs deleted file mode 100644 index 938850ee286..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap_partial.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! Our mmap/munmap support is a thin wrapper over Interpcx::allocate_ptr. Since the underlying -//! layer has much more UB than munmap does, we need to be sure we throw an unsupported error here. -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let ptr = libc::mmap( - std::ptr::null_mut(), - page_size::get() * 2, - libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, - -1, - 0, - ); - libc::munmap(ptr, 1); - //~^ ERROR: unsupported operation - } -} diff --git a/src/tools/miri/tests/fail/shims/munmap_partial.stderr b/src/tools/miri/tests/fail/shims/munmap_partial.stderr deleted file mode 100644 index 9a084c50437..00000000000 --- a/src/tools/miri/tests/fail/shims/munmap_partial.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: integer-to-pointer cast - --> $DIR/munmap_partial.rs:LL:CC - | -LL | libc::munmap(ptr, 1); - | ^^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast - | - = help: This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`, - = help: which means that Miri might miss pointer bugs in this program. - = help: See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation. - = help: To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead. - = help: You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics. - = help: Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning. - = note: BACKTRACE: - = note: inside `main` at $DIR/munmap_partial.rs:LL:CC - -error: unsupported operation: Miri only supports munmap calls that exactly unmap a region previously returned by mmap - --> $DIR/munmap_partial.rs:LL:CC - | -LL | libc::munmap(ptr, 1); - | ^^^^^^^^^^^^^^^^^^^^ Miri only supports munmap calls that exactly unmap a region previously returned by mmap - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/munmap_partial.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/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs deleted file mode 100644 index 94ca3496ed9..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_cond twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - libc::pthread_condattr_init(attr.as_mut_ptr()); - - let mut cond = MaybeUninit::::uninit(); - - libc::pthread_cond_init(cond.as_mut_ptr(), attr.as_ptr()); - - libc::pthread_cond_destroy(cond.as_mut_ptr()); - - libc::pthread_cond_destroy(cond.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr deleted file mode 100644 index ecfedf75370..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_cond_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs deleted file mode 100644 index 13e639a867d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_condattr twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - - libc::pthread_condattr_init(attr.as_mut_ptr()); - - libc::pthread_condattr_destroy(attr.as_mut_ptr()); - - libc::pthread_condattr_destroy(attr.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr deleted file mode 100644 index f39d909adbd..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_condattr_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs deleted file mode 100644 index 8b251073383..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// -// Check that if we pass NULL attribute, then we get the default mutex type. - -fn main() { - unsafe { - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, std::ptr::null() as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr deleted file mode 100644 index 4a138e6f8a2..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_NULL_deadlock.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs deleted file mode 100644 index 6c3cb738e29..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct Mutex(UnsafeCell); - -unsafe impl Send for Mutex {} -unsafe impl Sync for Mutex {} - -fn new_lock() -> Arc { - Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr deleted file mode 100644 index 599655a8692..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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 - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs deleted file mode 100644 index f443768819f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ignore-target-windows: No libc on Windows -// -// Check that if we do not set the mutex type, it is the default. - -fn main() { - unsafe { - let mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: Undefined Behavior: trying to acquire already locked default mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr deleted file mode 100644 index 8aea3f5c693..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_default_deadlock.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs deleted file mode 100644 index ec3965c7574..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR: destroyed a locked mutex - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr deleted file mode 100644 index a8ab948116e..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_destroy_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs deleted file mode 100644 index 622c3eaeae3..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_mutex twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - - let mut attr = MaybeUninit::::uninit(); - libc::pthread_mutexattr_init(attr.as_mut_ptr()); - - let mut mutex = MaybeUninit::::uninit(); - - libc::pthread_mutex_init(mutex.as_mut_ptr(), attr.as_ptr()); - - libc::pthread_mutex_destroy(mutex.as_mut_ptr()); - - libc::pthread_mutex_destroy(mutex.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr deleted file mode 100644 index 9620fdbd18b..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs deleted file mode 100644 index 5ea09fa5aac..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR: deadlock: the evaluated program deadlocked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr deleted file mode 100644 index b7877d3aa39..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs deleted file mode 100644 index 8ce7542edb8..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - unsafe { - let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed(); - assert_eq!( - libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), - 0, - ); - let mut mutex: libc::pthread_mutex_t = std::mem::zeroed(); - assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0); - assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0); - assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0); - libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR: was not locked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr deleted file mode 100644 index 754137b85b9..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_normal_unlock_unlocked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs deleted file mode 100644 index b56775252e4..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct Mutex(UnsafeCell); - -unsafe impl Send for Mutex {} -unsafe impl Sync for Mutex {} - -fn new_lock() -> Arc { - Arc::new(Mutex(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_mutex_lock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked a default mutex that was not locked by the current thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr deleted file mode 100644 index aa81b06fc80..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutex_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs deleted file mode 100644 index 474a277516d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity - -fn main() { - unsafe { - use core::mem::MaybeUninit; - let mut attr = MaybeUninit::::uninit(); - - libc::pthread_mutexattr_init(attr.as_mut_ptr()); - - libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - - libc::pthread_mutexattr_destroy(attr.as_mut_ptr()); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr deleted file mode 100644 index 82949047d2a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_mutexattr_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs deleted file mode 100644 index 603580ff58a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); - libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr deleted file mode 100644 index be73e7f1e2a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_read_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs deleted file mode 100644 index ae44f22d146..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_destroy(rw.get()); //~ ERROR: destroyed a locked rwlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr deleted file mode 100644 index bc2713a5ffb..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_destroy_write_locked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs deleted file mode 100644 index 800986f7506..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity - -fn main() { - unsafe { - let mut lock = libc::PTHREAD_RWLOCK_INITIALIZER; - - libc::pthread_rwlock_destroy(&mut lock); - - libc::pthread_rwlock_destroy(&mut lock); - //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr deleted file mode 100644 index 5004f84358d..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_double_destroy.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs deleted file mode 100644 index 782c95b6d2e..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0); - libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr deleted file mode 100644 index 075c8f0ef52..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs deleted file mode 100644 index 1b498ad8fcd..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr deleted file mode 100644 index 7dfa27b43d0..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs deleted file mode 100644 index 05f7e7a06c5..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - libc::pthread_rwlock_unlock(rw.get()); //~ ERROR: was not locked - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr deleted file mode 100644 index 1c25ac2c048..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_unlock_unlocked.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs deleted file mode 100644 index 201844615e1..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_rdlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr deleted file mode 100644 index 333fb1afb91..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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 - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs deleted file mode 100644 index 538f14ef89f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr deleted file mode 100644 index caab19a782f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs deleted file mode 100644 index b1d7e0492e5..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: deadlock - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr deleted file mode 100644 index 93bede54fcf..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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 - diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs deleted file mode 100644 index 2c963d36510..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -fn main() { - let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER); - unsafe { - assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0); - libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr deleted file mode 100644 index 30f5f447c71..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr +++ /dev/null @@ -1,12 +0,0 @@ -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/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs deleted file mode 100644 index dd099474d8f..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ignore-target-windows: No libc on Windows - -use std::cell::UnsafeCell; -use std::sync::Arc; -use std::thread; - -struct RwLock(UnsafeCell); - -unsafe impl Send for RwLock {} -unsafe impl Sync for RwLock {} - -fn new_lock() -> Arc { - Arc::new(RwLock(UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER))) -} - -fn main() { - unsafe { - let lock = new_lock(); - assert_eq!(libc::pthread_rwlock_wrlock(lock.0.get() as *mut _), 0); - - let lock_copy = lock.clone(); - thread::spawn(move || { - assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _), 0); //~ ERROR: Undefined Behavior: unlocked an rwlock that was not locked by the active thread - }) - .join() - .unwrap(); - } -} diff --git a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr b/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr deleted file mode 100644 index 5bf402c775a..00000000000 --- a/src/tools/miri/tests/fail/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr +++ /dev/null @@ -1,15 +0,0 @@ -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: BACKTRACE: - = 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 - diff --git a/src/tools/miri/tests/fail/tokio/sleep.rs b/src/tools/miri/tests/fail/tokio/sleep.rs deleted file mode 100644 index d96d778e6ca..00000000000 --- a/src/tools/miri/tests/fail/tokio/sleep.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full -//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86 -//@error-in-other-file: returning ready events from epoll_wait is not yet implemented -//@normalize-stderr-test: " += note:.*\n" -> "" - -use tokio::time::{sleep, Duration, Instant}; - -#[tokio::main] -async fn main() { - let start = Instant::now(); - sleep(Duration::from_secs(1)).await; - let time_elapsed = &start.elapsed().as_millis(); - assert!((1000..1100).contains(time_elapsed), "{}", time_elapsed); -} diff --git a/src/tools/miri/tests/fail/tokio/sleep.stderr b/src/tools/miri/tests/fail/tokio/sleep.stderr deleted file mode 100644 index ac2a984ed51..00000000000 --- a/src/tools/miri/tests/fail/tokio/sleep.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: unsupported operation: returning ready events from epoll_wait is not yet implemented - --> CARGO_REGISTRY/.../epoll.rs:LL:CC - | -LL | / syscall!(epoll_wait( -LL | | self.ep, -LL | | events.as_mut_ptr(), -LL | | events.capacity() as i32, -LL | | timeout, -LL | | )) - | |__________^ returning ready events from epoll_wait is not yet implemented - | - = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support - -error: aborting due to previous error - diff --git a/src/tools/miri/tests/fail/unsupported_incomplete_function.rs b/src/tools/miri/tests/fail/unsupported_incomplete_function.rs deleted file mode 100644 index 6ef842c9ccb..00000000000 --- a/src/tools/miri/tests/fail/unsupported_incomplete_function.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! `signal()` is special on Linux and macOS that it's only supported within libstd. -//! The implementation is not complete enough to permit user code to call it. -//@ignore-target-windows: No libc on Windows -//@normalize-stderr-test: "OS `.*`" -> "$$OS" - -fn main() { - unsafe { - libc::signal(libc::SIGPIPE, libc::SIG_IGN); - //~^ ERROR: unsupported operation: can't call foreign function `signal` - } -} diff --git a/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr b/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr deleted file mode 100644 index ec2bba61172..00000000000 --- a/src/tools/miri/tests/fail/unsupported_incomplete_function.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unsupported operation: can't call foreign function `signal` on $OS - --> $DIR/unsupported_incomplete_function.rs:LL:CC - | -LL | libc::signal(libc::SIGPIPE, libc::SIG_IGN); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `signal` on $OS - | - = 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: BACKTRACE: - = note: inside `main` at $DIR/unsupported_incomplete_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 - -- cgit 1.4.1-3-g733a5 From 0d5f51c290070335efa228c301d7ed5412a248ed Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 4 Aug 2023 11:22:06 +0000 Subject: Bump ui_test crate --- src/tools/miri/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 86ba460bb86..fa03be87596 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -36,7 +36,7 @@ libloading = "0.7" [dev-dependencies] colored = "2" -ui_test = "0.14" +ui_test = "0.14.1" rustc_version = "0.4" # Features chosen to match those required by env_logger, to avoid rebuilds regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } -- cgit 1.4.1-3-g733a5 From e7063679414915d6eb70905b53723a3c21f3a141 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 4 Aug 2023 11:26:55 +0000 Subject: Allow limiting the number of threads running in parallel --- src/tools/miri/tests/compiletest.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index d84f943a6f9..13415a409d6 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -1,6 +1,7 @@ use colored::*; use regex::bytes::Regex; use std::ffi::OsString; +use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::{env, process::Command}; use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling}; @@ -128,7 +129,10 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R eprintln!(" Compiler: {}", config.program.display()); ui_test::run_tests_generic( vec![config], - std::thread::available_parallelism().unwrap(), + std::env::var("MIRI_TEST_THREADS").map_or_else( + |_| std::thread::available_parallelism().unwrap(), + |threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap(), + ), args, // The files we're actually interested in (all `.rs` files). ui_test::default_file_filter, -- cgit 1.4.1-3-g733a5 From 9f4e7c69456d56d1ec5ae18a82b816135e0dcdf4 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 8 Aug 2023 07:23:16 +0000 Subject: Bump ui_test crate --- src/tools/miri/Cargo.lock | 38 +++++++++++---- src/tools/miri/Cargo.toml | 2 +- src/tools/miri/tests/compiletest.rs | 56 +++++++++++----------- .../tests/pass/backtrace/backtrace-api-v0.stdout | 2 +- .../tests/pass/backtrace/backtrace-api-v1.stdout | 2 +- 5 files changed, 61 insertions(+), 39 deletions(-) diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock index f0a145767b3..d236e4bbcb4 100644 --- a/src/tools/miri/Cargo.lock +++ b/src/tools/miri/Cargo.lock @@ -26,6 +26,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "annotate-snippets" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3b9d411ecbaf79885c6df4d75fff75858d5995ff25385657a28af47e82f9c36" +dependencies = [ + "unicode-width", + "yansi-term", +] + [[package]] name = "ansi_term" version = "0.12.1" @@ -216,12 +226,6 @@ dependencies = [ "windows-sys 0.45.0", ] -[[package]] -name = "distance" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9d8664cf849d7d0f3114a3a387d2f5e4303176d746d5a951aaddc66dfe9240" - [[package]] name = "encode_unicode" version = "0.3.6" @@ -372,6 +376,12 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "levenshtein" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" + [[package]] name = "libc" version = "0.2.148" @@ -937,10 +947,11 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.14.2" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d15b71b50d95aeb687f68289543b9cabdbec7afc277176ce9dfcf192c7035d" +checksum = "accffe020b57a6dd50014d457b5842c5a2ca73cd84f07d86d0a19c460a6509ae" dependencies = [ + "annotate-snippets", "anyhow", "bstr", "cargo-platform", @@ -949,9 +960,9 @@ dependencies = [ "colored", "comma", "crossbeam-channel", - "distance", "indicatif", "lazy_static", + "levenshtein", "prettydiff", "regex", "rustc_version", @@ -1147,3 +1158,12 @@ name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "yansi-term" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" +dependencies = [ + "winapi", +] diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index fa03be87596..0df2c160e2f 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -36,7 +36,7 @@ libloading = "0.7" [dev-dependencies] colored = "2" -ui_test = "0.14.1" +ui_test = "0.21.1" rustc_version = "0.4" # Features chosen to match those required by env_logger, to avoid rebuilds regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 13415a409d6..2a817172bc1 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -5,7 +5,7 @@ use std::num::NonZeroUsize; use std::path::{Path, PathBuf}; use std::{env, process::Command}; use ui_test::{color_eyre::Result, Config, Match, Mode, OutputConflictHandling}; -use ui_test::{status_emitter, CommandBuilder}; +use ui_test::{status_emitter, CommandBuilder, Format, RustfixMode}; fn miri_path() -> PathBuf { PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri"))) @@ -79,25 +79,17 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> program.args.push(flag); } - let bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0"); - let skip_ui_checks = env::var_os("MIRI_SKIP_UI_CHECKS").is_some(); - - let output_conflict_handling = match (bless, skip_ui_checks) { - (false, false) => OutputConflictHandling::Error("./miri test --bless".into()), - (true, false) => OutputConflictHandling::Bless, - (false, true) => OutputConflictHandling::Ignore, - (true, true) => panic!("cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"), - }; - let mut config = Config { target: Some(target.to_owned()), stderr_filters: STDERR.clone(), stdout_filters: STDOUT.clone(), mode, program, - output_conflict_handling, out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"), edition: Some("2021".into()), + threads: std::env::var("MIRI_TEST_THREADS") + .ok() + .map(|threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap()), ..Config::rustc(path) }; @@ -121,25 +113,31 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) -> } fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> Result<()> { - let config = test_config(target, path, mode, with_dependencies); + let mut config = test_config(target, path, mode, with_dependencies); // Handle command-line arguments. - let args = ui_test::Args::test(); - let quiet = args.quiet; + let args = ui_test::Args::test()?; + let default_bless = env::var_os("RUSTC_BLESS").is_some_and(|v| v != "0"); + config.with_args(&args, default_bless); + if let OutputConflictHandling::Error(msg) = &mut config.output_conflict_handling { + *msg = "./miri test --bless".into(); + } + if env::var_os("MIRI_SKIP_UI_CHECKS").is_some() { + assert!(!default_bless, "cannot use RUSTC_BLESS and MIRI_SKIP_UI_CHECKS at the same time"); + config.output_conflict_handling = OutputConflictHandling::Ignore; + } eprintln!(" Compiler: {}", config.program.display()); ui_test::run_tests_generic( vec![config], - std::env::var("MIRI_TEST_THREADS").map_or_else( - |_| std::thread::available_parallelism().unwrap(), - |threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap(), - ), - args, // The files we're actually interested in (all `.rs` files). ui_test::default_file_filter, // This could be used to overwrite the `Config` on a per-test basis. - |_, _| {}, + |_, _, _| {}, ( - if quiet { status_emitter::Text::quiet() } else { status_emitter::Text::verbose() }, + match args.format { + Format::Terse => status_emitter::Text::quiet(), + Format::Pretty => status_emitter::Text::verbose(), + }, status_emitter::Gha:: { name: format!("{mode:?} {path} ({target})"), }, @@ -244,13 +242,13 @@ fn main() -> Result<()> { ui(Mode::Pass, "tests/pass-dep", &target, WithDependencies)?; ui(Mode::Panic, "tests/panic", &target, WithDependencies)?; ui( - Mode::Fail { require_patterns: true, rustfix: false }, + Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled }, "tests/fail", &target, WithoutDependencies, )?; ui( - Mode::Fail { require_patterns: true, rustfix: false }, + Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled }, "tests/fail-dep", &target, WithDependencies, @@ -258,7 +256,7 @@ fn main() -> Result<()> { if cfg!(target_os = "linux") { ui(Mode::Pass, "tests/extern-so/pass", &target, WithoutDependencies)?; ui( - Mode::Fail { require_patterns: true, rustfix: false }, + Mode::Fail { require_patterns: true, rustfix: RustfixMode::Disabled }, "tests/extern-so/fail", &target, WithoutDependencies, @@ -270,8 +268,12 @@ fn main() -> Result<()> { fn run_dep_mode(target: String, mut args: impl Iterator) -> Result<()> { let path = args.next().expect("./miri run-dep must be followed by a file name"); - let mut config = - test_config(&target, "", Mode::Yolo { rustfix: false }, /* with dependencies */ true); + let mut config = test_config( + &target, + "", + Mode::Yolo { rustfix: RustfixMode::Disabled }, + /* with dependencies */ true, + ); config.program.args.clear(); // We want to give the user full control over flags let dep_args = config.build_dependencies()?; diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stdout b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stdout index 2fe31dd0e6b..c9cab268168 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stdout +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stdout @@ -1,5 +1,5 @@ $DIR/backtrace-api-v0.rs:24:14 (func_d) $DIR/backtrace-api-v0.rs:20:5 (func_c) -$DIR/backtrace-api-v0.rs:9:5 (func_b) +$DIR/backtrace-api-v0.rs:9:5 (func_b::) $DIR/backtrace-api-v0.rs:5:5 (func_a) $DIR/backtrace-api-v0.rs:29:18 (main) diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stdout b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stdout index 0d2ae3b516a..e145c167e88 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stdout +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stdout @@ -1,5 +1,5 @@ $DIR/backtrace-api-v1.rs:27:9 (func_d) $DIR/backtrace-api-v1.rs:20:5 (func_c) -$DIR/backtrace-api-v1.rs:9:5 (func_b) +$DIR/backtrace-api-v1.rs:9:5 (func_b::) $DIR/backtrace-api-v1.rs:5:5 (func_a) $DIR/backtrace-api-v1.rs:34:18 (main) -- cgit 1.4.1-3-g733a5 From 5f440dd0696cf54feb560601c7bc383e49511f1a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 24 Sep 2023 12:44:54 -0400 Subject: GC the Stacked Borrows allocation history --- src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock | 7 +++++++ src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml | 8 ++++++++ src/tools/miri/bench-cargo-miri/invalidate/src/main.rs | 4 ++++ src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs | 7 +++++++ src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs | 1 + 5 files changed, 27 insertions(+) create mode 100644 src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock create mode 100644 src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml create mode 100644 src/tools/miri/bench-cargo-miri/invalidate/src/main.rs diff --git a/src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock b/src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock new file mode 100644 index 00000000000..7bf23225ea5 --- /dev/null +++ b/src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "invalidate" +version = "0.1.0" diff --git a/src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml b/src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml new file mode 100644 index 00000000000..14cf0882f0b --- /dev/null +++ b/src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "invalidate" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/miri/bench-cargo-miri/invalidate/src/main.rs b/src/tools/miri/bench-cargo-miri/invalidate/src/main.rs new file mode 100644 index 00000000000..fa8deb851c3 --- /dev/null +++ b/src/tools/miri/bench-cargo-miri/invalidate/src/main.rs @@ -0,0 +1,4 @@ +fn main() { + // The end of the range is just chosen to make the benchmark run for a few seconds. + for _ in 0..200_000 {} +} diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs index 9b0f13dd62c..1ef30cb9fad 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs @@ -1,6 +1,7 @@ use smallvec::SmallVec; use std::fmt; +use rustc_data_structures::fx::FxHashSet; use rustc_middle::mir::interpret::{alloc_range, AllocId, AllocRange, InterpError}; use rustc_span::{Span, SpanData}; use rustc_target::abi::Size; @@ -233,6 +234,12 @@ impl AllocHistory { protectors: SmallVec::new(), } } + + pub fn retain(&mut self, live_tags: &FxHashSet) { + self.invalidations.retain(|event| live_tags.contains(&event.tag)); + self.creations.retain(|event| live_tags.contains(&event.retag.new_tag)); + self.protectors.retain(|event| live_tags.contains(&event.tag)); + } } impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> { diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index a54bd32cd40..e670dcef330 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -456,6 +456,7 @@ impl Stacks { stack.retain(live_tags); } } + self.history.retain(live_tags); self.modified_since_last_gc = false; } } -- cgit 1.4.1-3-g733a5 From 1ec85a84413c527449ea1772b3f2c2f77b9be3d0 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 25 Sep 2023 10:31:05 +0000 Subject: Document new env var --- src/tools/miri/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index f6a023181d8..6127eada222 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -478,6 +478,8 @@ Moreover, Miri recognizes some environment variables: * `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same purpose. +* `MIRI_TEST_THREADS` (recognized by the test suite): set the number of threads to use for running tests. + By default the number of cores is used. * `MIRI_NO_STD` (recognized by `cargo miri` and the test suite) makes sure that the target's sysroot is built without libstd. This allows testing and running no_std programs. * `RUSTC_BLESS` (recognized by the test suite and `cargo-miri-test/run-test.py`): overwrite all -- cgit 1.4.1-3-g733a5 From 71aea48fc6e918922b069eb3346f54a33d9d7542 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 25 Sep 2023 10:32:24 +0000 Subject: Explain single element vector --- src/tools/miri/tests/compiletest.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index 2a817172bc1..fe799216f0e 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -128,6 +128,8 @@ fn run_tests(mode: Mode, path: &str, target: &str, with_dependencies: bool) -> R } eprintln!(" Compiler: {}", config.program.display()); ui_test::run_tests_generic( + // Only run one test suite. In the future we can add all test suites to one `Vec` and run + // them all at once, making best use of systems with high parallelism. vec![config], // The files we're actually interested in (all `.rs` files). ui_test::default_file_filter, -- cgit 1.4.1-3-g733a5 From ee30aaf7ea5ac3db40cd6da4172e214c5dbd9ef0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 25 Sep 2023 13:38:26 +0200 Subject: fix normalization in backtrace-api tests also remove a normalization rule that doesn't seem to apply --- src/tools/miri/tests/compiletest.rs | 4 +--- src/tools/miri/tests/pass/backtrace/backtrace-api-v0.rs | 2 ++ .../miri/tests/pass/backtrace/backtrace-api-v0.stderr | 15 ++++++++++++++- src/tools/miri/tests/pass/backtrace/backtrace-api-v1.rs | 2 ++ .../miri/tests/pass/backtrace/backtrace-api-v1.stderr | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs index fe799216f0e..035846f0ef9 100644 --- a/src/tools/miri/tests/compiletest.rs +++ b/src/tools/miri/tests/compiletest.rs @@ -179,8 +179,6 @@ regexes! { 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 specific alignments @@ -192,7 +190,7 @@ regexes! { // Windows file paths r"\\" => "/", // erase Rust stdlib path - "[^ `]*/(rust[^/]*|checkout)/library/" => "RUSTLIB/", + "[^ \n`]*/(rust[^/]*|checkout)/library/" => "RUSTLIB/", // erase platform file paths "sys/[a-z]+/" => "sys/PLATFORM/", // erase paths into the crate registry diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.rs b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.rs index 5cd12959ca4..8d3173da400 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.rs +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.rs @@ -41,6 +41,8 @@ fn main() { eprintln!("{}", out); // Print the 'main' frame (and everything before it) to stdout, skipping // the printing of internal (and possibly fragile) libstd frames. + // Stdout is less normalized so we see more, but it also means we can print less + // as platform differences would lead to test suite failures. if !seen_main { println!("{}", out); seen_main = name == "main"; diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stderr b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stderr index ee556b3e4a0..bc24d6de734 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stderr +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v0.stderr @@ -2,4 +2,17 @@ $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 RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +$DIR/backtrace-api-v0.rs:LL:CC (main) +RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) +RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) +RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) +RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2}) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) +RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start) diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.rs b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.rs index 1e35574b39b..ad05271ca51 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.rs +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.rs @@ -54,6 +54,8 @@ fn main() { eprintln!("{}", out); // Print the 'main' frame (and everything before it) to stdout, skipping // the printing of internal (and possibly fragile) libstd frames. + // Stdout is less normalized so we see more, but it also means we can print less + // as platform differences would lead to test suite failures. if !seen_main { println!("{}", out); seen_main = name == "main"; diff --git a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr index 7dc281af31d..246e54becd8 100644 --- a/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr +++ b/src/tools/miri/tests/pass/backtrace/backtrace-api-v1.stderr @@ -2,4 +2,17 @@ $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 RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +$DIR/backtrace-api-v1.rs:LL:CC (main) +RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) +RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC (std::sys_common::backtrace::__rust_begin_short_backtrace) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) +RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) +RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#2}) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) +RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) +RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal) +RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start) -- cgit 1.4.1-3-g733a5 From fc0d833f6fb9876c367bb738927525102e5761a7 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Wed, 27 Sep 2023 05:38:37 +0000 Subject: Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 458bba9a616..3f1babf5323 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -42ca6e4e5760a548a6fa858482de6d237f6fb3b8 +d206f2c0857eb879877f27508139dd62a40294c3 -- cgit 1.4.1-3-g733a5 From c8a44b1eaf5aed5cf8e57340f1ac56c9bad08acf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 27 Sep 2023 08:50:16 +0200 Subject: clippy --- src/tools/miri/cargo-miri/src/phases.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/cargo-miri/src/phases.rs b/src/tools/miri/cargo-miri/src/phases.rs index 80ce6325582..d655df6d994 100644 --- a/src/tools/miri/cargo-miri/src/phases.rs +++ b/src/tools/miri/cargo-miri/src/phases.rs @@ -10,7 +10,7 @@ use rustc_version::VersionMeta; use crate::{setup::*, util::*}; -const CARGO_MIRI_HELP: &str = r#"Runs binary crates and tests in Miri +const CARGO_MIRI_HELP: &str = r"Runs binary crates and tests in Miri Usage: cargo miri [subcommand] [...] [--] [...] @@ -31,7 +31,7 @@ Examples: This will print the path to the generated sysroot (and nothing else) on stdout. stderr will still contain progress information about how the build is doing. -"#; +"; fn show_help() { println!("{CARGO_MIRI_HELP}"); -- cgit 1.4.1-3-g733a5 From 3b091cb5044ecc956a87993870276311a0e15340 Mon Sep 17 00:00:00 2001 From: The Miri Conjob Bot Date: Thu, 28 Sep 2023 05:11:51 +0000 Subject: Preparing for merge from rustc --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 3f1babf5323..07dd52ce941 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -d206f2c0857eb879877f27508139dd62a40294c3 +2ba4eb2d49e774b5fbc2a06258ac7b0f60b92b7e -- cgit 1.4.1-3-g733a5 From e0f4ab84a7e27e6449252ed416ceeb2fbb0fbbbe Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 28 Sep 2023 16:42:07 +0200 Subject: update lockfile --- Cargo.lock | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 014e14e5399..2ba0a9b895c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2419,7 +2419,7 @@ dependencies = [ "rustc_version", "serde", "smallvec", - "ui_test 0.11.7", + "ui_test 0.21.2", ] [[package]] @@ -5621,18 +5621,23 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "ui_test" -version = "0.11.7" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c" +checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971" dependencies = [ + "annotate-snippets", + "anyhow", "bstr", "cargo-platform", "cargo_metadata", "color-eyre", "colored", + "comma", "crossbeam-channel", - "diff", + "indicatif", "lazy_static", + "levenshtein", + "prettydiff", "regex", "rustc_version", "rustfix", @@ -5643,9 +5648,9 @@ dependencies = [ [[package]] name = "ui_test" -version = "0.20.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971" +checksum = "aaf4bf7c184b8dfc7a4d3b90df789b1eb992ee42811cd115f32a7a1eb781058d" dependencies = [ "annotate-snippets", "anyhow", -- cgit 1.4.1-3-g733a5