diff options
| author | bors <bors@rust-lang.org> | 2022-11-20 09:49:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-11-20 09:49:34 +0000 |
| commit | c26b510dbcca6b8a3e7ec4c4f97def1615e6cd64 (patch) | |
| tree | 37a8fc7431dfd5454237fc514c3e76d93cc4eb6f | |
| parent | 0a9e5e8e81959195ff5671d5af20097745381477 (diff) | |
| parent | 772d521616f09470dadd65c609273267fa576e4d (diff) | |
| download | rust-c26b510dbcca6b8a3e7ec4c4f97def1615e6cd64.tar.gz rust-c26b510dbcca6b8a3e7ec4c4f97def1615e6cd64.zip | |
Auto merge of #2681 - RalfJung:seed, r=oli-obk
make miri-seed a regular integer, and also set layout-seed in many-seeds This makes the seed format consistent between `-Zlayout-seed` and `-Zmiri-seed`.
| -rw-r--r-- | src/tools/miri/README.md | 4 | ||||
| -rwxr-xr-x | src/tools/miri/miri | 4 | ||||
| -rw-r--r-- | src/tools/miri/src/bin/miri.rs | 7 | ||||
| -rwxr-xr-x | src/tools/miri/test-cargo-miri/run-test.py | 2 |
4 files changed, 8 insertions, 9 deletions
diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 124769c59a3..dac0a9820b9 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -195,7 +195,7 @@ randomness that is used to determine allocation base addresses. The following snippet calls Miri in a loop with different values for the seed: ``` -for SEED in $({ echo obase=16; seq 0 255; } | bc); do +for SEED in $(seq 0 255); do echo "Trying seed: $SEED" MIRIFLAGS=-Zmiri-seed=$SEED cargo miri test || { echo "Failing seed: $SEED"; break; }; done @@ -303,7 +303,7 @@ environment variable. We first document the most relevant and most commonly used tell what it is doing when a program just keeps running. You can customize how frequently the report is printed via `-Zmiri-report-progress=<blocks>`, which prints the report every N basic blocks. -* `-Zmiri-seed=<hex>` configures the seed of the RNG that Miri uses to resolve non-determinism. This +* `-Zmiri-seed=<num>` configures the seed of the RNG that Miri uses to resolve non-determinism. This RNG is used to pick base addresses for allocations, to determine preemption and failure of `compare_exchange_weak`, and to control store buffering for weak memory emulation. When isolation is enabled (the default), this is also used to emulate system entropy. The default seed is 0. You diff --git a/src/tools/miri/miri b/src/tools/miri/miri index fc6b6e2f4fd..38d36898768 100755 --- a/src/tools/miri/miri +++ b/src/tools/miri/miri @@ -174,9 +174,9 @@ rustc-push) fi ;; many-seeds) - for SEED in $({ echo obase=16; seq 0 255; } | bc); do + for SEED in $(seq 0 255); do echo "Trying seed: $SEED" - MIRIFLAGS="$MIRIFLAGS -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; } + MIRIFLAGS="$MIRIFLAGS -Zlayout-seed=$SEED -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; } done exit 0 ;; diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index e673ea67dbc..ffe89921d98 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -394,10 +394,9 @@ fn main() { if miri_config.seed.is_some() { show_error!("Cannot specify -Zmiri-seed multiple times!"); } - let seed = u64::from_str_radix(param, 16) - .unwrap_or_else(|_| show_error!( - "-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and must fit into a u64 (max 16 characters)" - )); + let seed = param.parse::<u64>().unwrap_or_else(|_| { + show_error!("-Zmiri-seed must be an integer that fits into u64") + }); miri_config.seed = Some(seed); } else if let Some(_param) = arg.strip_prefix("-Zmiri-env-exclude=") { show_error!( diff --git a/src/tools/miri/test-cargo-miri/run-test.py b/src/tools/miri/test-cargo-miri/run-test.py index c611b9c44be..46b3afa70e5 100755 --- a/src/tools/miri/test-cargo-miri/run-test.py +++ b/src/tools/miri/test-cargo-miri/run-test.py @@ -133,7 +133,7 @@ def test_cargo_miri_test(): test("`cargo miri test`", cargo_miri("test"), default_ref, "test.stderr-empty.ref", - env={'MIRIFLAGS': "-Zmiri-permissive-provenance -Zmiri-seed=feed"}, + env={'MIRIFLAGS': "-Zmiri-permissive-provenance -Zmiri-seed=4242"}, ) test("`cargo miri test` (no isolation, no doctests)", cargo_miri("test") + ["--bins", "--tests"], # no `--lib`, we disabled that in `Cargo.toml` |
