Skip to content

Commit 772d521

Browse files
committed
make miri-seed a regular integer, and also set layout-seed in many-seeds
1 parent 0a9e5e8 commit 772d521

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/tools/miri/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ randomness that is used to determine allocation base addresses. The following
195195
snippet calls Miri in a loop with different values for the seed:
196196

197197
```
198-
for SEED in $({ echo obase=16; seq 0 255; } | bc); do
198+
for SEED in $(seq 0 255); do
199199
echo "Trying seed: $SEED"
200200
MIRIFLAGS=-Zmiri-seed=$SEED cargo miri test || { echo "Failing seed: $SEED"; break; };
201201
done
@@ -303,7 +303,7 @@ environment variable. We first document the most relevant and most commonly used
303303
tell what it is doing when a program just keeps running. You can customize how frequently the
304304
report is printed via `-Zmiri-report-progress=<blocks>`, which prints the report every N basic
305305
blocks.
306-
* `-Zmiri-seed=<hex>` configures the seed of the RNG that Miri uses to resolve non-determinism. This
306+
* `-Zmiri-seed=<num>` configures the seed of the RNG that Miri uses to resolve non-determinism. This
307307
RNG is used to pick base addresses for allocations, to determine preemption and failure of
308308
`compare_exchange_weak`, and to control store buffering for weak memory emulation. When isolation
309309
is enabled (the default), this is also used to emulate system entropy. The default seed is 0. You

src/tools/miri/miri

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ rustc-push)
174174
fi
175175
;;
176176
many-seeds)
177-
for SEED in $({ echo obase=16; seq 0 255; } | bc); do
177+
for SEED in $(seq 0 255); do
178178
echo "Trying seed: $SEED"
179-
MIRIFLAGS="$MIRIFLAGS -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; }
179+
MIRIFLAGS="$MIRIFLAGS -Zlayout-seed=$SEED -Zmiri-seed=$SEED" $@ || { echo "Failing seed: $SEED"; break; }
180180
done
181181
exit 0
182182
;;

src/tools/miri/src/bin/miri.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,9 @@ fn main() {
394394
if miri_config.seed.is_some() {
395395
show_error!("Cannot specify -Zmiri-seed multiple times!");
396396
}
397-
let seed = u64::from_str_radix(param, 16)
398-
.unwrap_or_else(|_| show_error!(
399-
"-Zmiri-seed should only contain valid hex digits [0-9a-fA-F] and must fit into a u64 (max 16 characters)"
400-
));
397+
let seed = param.parse::<u64>().unwrap_or_else(|_| {
398+
show_error!("-Zmiri-seed must be an integer that fits into u64")
399+
});
401400
miri_config.seed = Some(seed);
402401
} else if let Some(_param) = arg.strip_prefix("-Zmiri-env-exclude=") {
403402
show_error!(

src/tools/miri/test-cargo-miri/run-test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_cargo_miri_test():
133133
test("`cargo miri test`",
134134
cargo_miri("test"),
135135
default_ref, "test.stderr-empty.ref",
136-
env={'MIRIFLAGS': "-Zmiri-permissive-provenance -Zmiri-seed=feed"},
136+
env={'MIRIFLAGS': "-Zmiri-permissive-provenance -Zmiri-seed=4242"},
137137
)
138138
test("`cargo miri test` (no isolation, no doctests)",
139139
cargo_miri("test") + ["--bins", "--tests"], # no `--lib`, we disabled that in `Cargo.toml`

0 commit comments

Comments
 (0)