Skip to content

Commit cfb66a9

Browse files
committed
Fix path replacement in miri example
1 parent bc46e45 commit cfb66a9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

listings/ch20-advanced-features/listing-20-07/output.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
$ cargo +nightly miri run
22
Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example)
33
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
4-
Running `file:///home/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo-miri runner target/miri/aarch64-apple-darwin/debug/unsafe-example`
4+
Running `file:///home/.rustup/toolchains/nightly/bin/cargo-miri runner target/miri/debug/unsafe-example`
55
warning: integer-to-pointer cast
6-
--> src/main.rs:6:13
6+
--> src/main.rs:5:13
77
|
8-
6 | let r = address as *mut i32;
8+
5 | let r = address as *mut i32;
99
| ^^^^^^^^^^^^^^^^^^^ integer-to-pointer cast
1010
|
1111
= help: this program is using integer-to-pointer casts or (equivalently) `ptr::with_exposed_provenance`, which means that Miri might miss pointer bugs in this program
@@ -14,18 +14,18 @@ warning: integer-to-pointer cast
1414
= help: you can then set `MIRIFLAGS=-Zmiri-strict-provenance` to ensure you are not relying on `with_exposed_provenance` semantics
1515
= help: alternatively, `MIRIFLAGS=-Zmiri-permissive-provenance` disables this warning
1616
= note: BACKTRACE:
17-
= note: inside `main` at src/main.rs:6:13: 6:32
17+
= note: inside `main` at src/main.rs:5:13: 5:32
1818

1919
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 40000 bytes, but got 0x1234[noalloc] which is a dangling pointer (it has no provenance)
20-
--> src/main.rs:8:35
20+
--> src/main.rs:7:35
2121
|
22-
8 | let values: &[i32] = unsafe { slice::from_raw_parts_mut(r, 10000) };
22+
7 | let values: &[i32] = unsafe { slice::from_raw_parts_mut(r, 10000) };
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
2424
|
2525
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
2626
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
2727
= note: BACKTRACE:
28-
= note: inside `main` at src/main.rs:8:35: 8:70
28+
= note: inside `main` at src/main.rs:7:35: 7:70
2929

3030
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
3131

tools/update-rustc.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ find -s listings -name output.txt -print0 | while IFS= read -r -d '' f; do
8080
#
8181
# - Replaces the path up to `.rustup/toolchains` with `file:///home`, while
8282
# preserving leading spaces and the `-->`.
83-
# - Replaces the version-and-architecture-tripl with just the version, so
83+
# - Replaces the version-and-architecture-triple with just the version, so
8484
# e.g. `1.82-aarch64-apple-darwin` becomes `1.82`.
8585
sed -i '' -E -e 's@^([[:space:]]*-->[[:space:]]+).*(\.rustup/toolchains/[[:digit:]]+\.[[:digit:]]+)([^/]*)@\1file:///home/\2@' "${full_output_path}"
8686

87+
# Similarly, replace Miri paths
88+
sed -i '' -E -e "s@Running \`(.*)\.rustup/toolchains/nightly([^/]*)/bin/cargo-miri runner target/miri/([^/]*)/debug/([^/]*)@Running \`file:///home/.rustup/toolchains/nightly/bin/cargo-miri runner target/miri/debug/\4@" "${full_output_path}"
89+
8790
# Restore the previous compile time, if there is one
8891
if [ -n "${compile_time}" ]; then
8992
sed -i '' -E -e "s/Finished \`(dev|test)\` profile \[unoptimized \+ debuginfo] target\(s\) in [0-9.]*/Finished \`\1\` profile [unoptimized + debuginfo] target(s) in ${compile_time}/" "${full_output_path}"

0 commit comments

Comments
 (0)