From 1d79b60a1eed7fd1b176de1cbe2fa44ee158cc0d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 1 Apr 2022 23:59:16 -0400 Subject: [PATCH] make strict-provenance imply check-number-validity --- README.md | 3 ++- src/bin/miri.rs | 1 + tests/run-pass/btreemap.rs | 2 +- tests/run-pass/concurrency/sync.rs | 2 +- tests/run-pass/concurrency/thread_locals.rs | 2 +- tests/run-pass/rc.rs | 2 +- tests/run-pass/slices.rs | 2 +- tests/run-pass/strings.rs | 2 +- tests/run-pass/vec.rs | 2 +- tests/run-pass/vecdeque.rs | 2 +- 10 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2203a0643a9..d394eb3cfbe 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,8 @@ environment variable: * `-Zmiri-strict-provenance` enables [strict provenance](https://github.com/rust-lang/rust/issues/95228) checking in Miri. This means that casting an integer to a pointer yields a result with 'invalid' provenance, i.e., with provenance - that cannot be used for any memory access. Also implies `-Zmiri-tag-raw-pointers`. + that cannot be used for any memory access. Also implies `-Zmiri-tag-raw-pointers` and + `-Zmiri-check-number-validity`. * `-Zmiri-symbolic-alignment-check` makes the alignment check more strict. By default, alignment is checked by casting the pointer to an integer, and making sure that is a multiple of the alignment. This can lead to cases where a diff --git a/src/bin/miri.rs b/src/bin/miri.rs index 5a9c96ef99b..be4776f459c 100644 --- a/src/bin/miri.rs +++ b/src/bin/miri.rs @@ -366,6 +366,7 @@ fn main() { "-Zmiri-strict-provenance" => { miri_config.strict_provenance = true; miri_config.tag_raw = true; + miri_config.check_number_validity = true; } "-Zmiri-track-raw-pointers" => { eprintln!( diff --git a/tests/run-pass/btreemap.rs b/tests/run-pass/btreemap.rs index 4e11aa5917e..413d7ef53d1 100644 --- a/tests/run-pass/btreemap.rs +++ b/tests/run-pass/btreemap.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance #![feature(btree_drain_filter)] use std::collections::{BTreeMap, BTreeSet}; use std::mem; diff --git a/tests/run-pass/concurrency/sync.rs b/tests/run-pass/concurrency/sync.rs index 95ede8e6c02..5e43fea9686 100644 --- a/tests/run-pass/concurrency/sync.rs +++ b/tests/run-pass/concurrency/sync.rs @@ -1,5 +1,5 @@ // ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-disable-isolation -Zmiri-strict-provenance use std::sync::{Arc, Barrier, Condvar, Mutex, Once, RwLock}; use std::thread; diff --git a/tests/run-pass/concurrency/thread_locals.rs b/tests/run-pass/concurrency/thread_locals.rs index 8b4f2a6f79d..7938284bd63 100644 --- a/tests/run-pass/concurrency/thread_locals.rs +++ b/tests/run-pass/concurrency/thread_locals.rs @@ -1,5 +1,5 @@ // ignore-windows: Concurrency on Windows is not supported yet. -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance //! The main purpose of this test is to check that if we take a pointer to //! thread's `t1` thread-local `A` and send it to another thread `t2`, diff --git a/tests/run-pass/rc.rs b/tests/run-pass/rc.rs index fcc5156de89..6d51825fc0d 100644 --- a/tests/run-pass/rc.rs +++ b/tests/run-pass/rc.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance #![feature(new_uninit)] #![feature(get_mut_unchecked)] diff --git a/tests/run-pass/slices.rs b/tests/run-pass/slices.rs index f9d0b4eb8ea..b6537b4f1b4 100644 --- a/tests/run-pass/slices.rs +++ b/tests/run-pass/slices.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance #![feature(new_uninit)] #![feature(slice_as_chunks)] #![feature(slice_partition_dedup)] diff --git a/tests/run-pass/strings.rs b/tests/run-pass/strings.rs index 5c36168a6ea..77ecaed4fe9 100644 --- a/tests/run-pass/strings.rs +++ b/tests/run-pass/strings.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance fn empty() -> &'static str { "" diff --git a/tests/run-pass/vec.rs b/tests/run-pass/vec.rs index 0d4c8016cdb..788f05ce977 100644 --- a/tests/run-pass/vec.rs +++ b/tests/run-pass/vec.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance // Gather all references from a mutable iterator and make sure Miri notices if // using them is dangerous. fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator) { diff --git a/tests/run-pass/vecdeque.rs b/tests/run-pass/vecdeque.rs index 8e8b395cbd9..0cba0165cae 100644 --- a/tests/run-pass/vecdeque.rs +++ b/tests/run-pass/vecdeque.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmiri-strict-provenance -Zmiri-check-number-validity +// compile-flags: -Zmiri-strict-provenance use std::collections::VecDeque; fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator) {