Skip to content

Commit 4eb30bc

Browse files
authored
Rollup merge of rust-lang#115049 - RalfJung:miri, r=RalfJung
update Miri r? `@ghost`
2 parents e5e7d16 + 9a3cb9e commit 4eb30bc

File tree

11 files changed

+41
-13
lines changed

11 files changed

+41
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,7 @@ dependencies = [
23342334
"rand",
23352335
"regex",
23362336
"rustc_version",
2337+
"serde",
23372338
"smallvec",
23382339
"ui_test",
23392340
]

src/tools/miri/CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,17 @@ to `.vscode/settings.json` in your local Miri clone:
165165
{
166166
"rust-analyzer.rustc.source": "discover",
167167
"rust-analyzer.linkedProjects": [
168-
"./Cargo.toml",
169-
"./cargo-miri/Cargo.toml"
168+
"Cargo.toml",
169+
"cargo-miri/Cargo.toml",
170+
"miri-script/Cargo.toml",
170171
],
171-
"rust-analyzer.checkOnSave.overrideCommand": [
172+
"rust-analyzer.check.overrideCommand": [
172173
"env",
173174
"MIRI_AUTO_OPS=no",
174175
"./miri",
175176
"cargo",
176177
"clippy", // make this `check` when working with a locally built rustc
177-
"--message-format=json"
178+
"--message-format=json",
178179
],
179180
// Contrary to what the name suggests, this also affects proc macros.
180181
"rust-analyzer.cargo.buildScripts.overrideCommand": [

src/tools/miri/Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ dependencies = [
443443
"rand",
444444
"regex",
445445
"rustc_version",
446+
"serde",
446447
"smallvec",
447448
"ui_test",
448449
]

src/tools/miri/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ rustc_version = "0.4"
4141
# Features chosen to match those required by env_logger, to avoid rebuilds
4242
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }
4343
lazy_static = "1.4.0"
44+
# Pin a version of serde without intransparent unreproducible binary blobs.
45+
serde = { version = "1.0, < 1.0.172", features = ["derive"] }
4446

4547
[package.metadata.rust-analyzer]
4648
# This crate uses #[feature(rustc_private)].

src/tools/miri/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ Some native rustc `-Z` flags are also very relevant for Miri:
458458
Moreover, Miri recognizes some environment variables:
459459

460460
* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup
461-
should be skipped. If it is set to any value, they are skipped. This is used for avoiding infinite
462-
recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
461+
should be skipped. If it is set to `no`, they are skipped. This is used to allow automated IDE
462+
actions to avoid the auto ops.
463463
* `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during
464464
Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri].
465465
* `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra

src/tools/miri/cargo-miri/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ rustc-build-sysroot = "0.4.1"
2222

2323
# Enable some feature flags that dev-dependencies need but dependencies
2424
# do not. This makes `./miri install` after `./miri build` faster.
25-
serde = { version = "*", features = ["derive"] }
25+
# Pin a version of serde without intransparent unreproducible binary blobs.
26+
serde = { version = "1.0, < 1.0.172", features = ["derive"] }
2627

2728
[build-dependencies]
2829
rustc_tools_util = "0.3"

src/tools/miri/miri-script/src/commands.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ impl MiriEnv {
5757

5858
impl Command {
5959
fn auto_actions() -> Result<()> {
60+
if env::var_os("MIRI_AUTO_OPS").is_some_and(|x| x == "no") {
61+
return Ok(());
62+
}
63+
6064
let miri_dir = miri_dir()?;
6165
let auto_everything = path!(miri_dir / ".auto-everything").exists();
6266
let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists();
@@ -78,6 +82,7 @@ impl Command {
7882
}
7983

8084
pub fn exec(self) -> Result<()> {
85+
// First, and crucially only once, run the auto-actions -- but not for all commands.
8186
match &self {
8287
Command::Install { .. }
8388
| Command::Build { .. }
@@ -93,6 +98,7 @@ impl Command {
9398
| Command::Bench { .. }
9499
| Command::RustcPush { .. } => {}
95100
}
101+
// Then run the actual command.
96102
match self {
97103
Command::Install { flags } => Self::install(flags),
98104
Command::Build { flags } => Self::build(flags),

src/tools/miri/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
656ee47db32e882fb02913f6204e09cc7a41a50e
1+
c40cfcf0494ff7506e753e750adb00eeea839f9c

src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,31 @@ mod transition {
6868
fn foreign_read(state: PermissionPriv, protected: bool) -> Option<PermissionPriv> {
6969
use Option::*;
7070
Some(match state {
71+
// Non-writeable states just ignore foreign reads.
72+
non_writeable @ (Frozen | Disabled) => non_writeable,
73+
// Writeable states are more tricky, and depend on whether things are protected.
7174
// The inner data `ty_is_freeze` of `Reserved` is always irrelevant for Read
7275
// accesses, since the data is not being mutated. Hence the `{ .. }`
73-
res @ Reserved { .. } if !protected => res,
74-
Reserved { .. } => Frozen, // protected reserved
76+
res @ Reserved { .. } =>
77+
if protected {
78+
// Someone else read, make sure we won't write.
79+
// We could make this `Disabled` but it doesn't look like we get anything out of that extra UB.
80+
Frozen
81+
} else {
82+
// Before activation and without protectors, foreign reads are fine.
83+
// That's the entire point of 2-phase borrows.
84+
res
85+
},
7586
Active =>
7687
if protected {
88+
// We wrote, someone else reads -- that's bad.
89+
// (If this is initialized, this move-to-protected will mean insta-UB.)
7790
Disabled
7891
} else {
92+
// We don't want to disable here to allow read-read reordering: it is crucial
93+
// that the foreign read does not invalidate future reads through this tag.
7994
Frozen
8095
},
81-
non_writeable @ (Frozen | Disabled) => non_writeable,
8296
})
8397
}
8498

src/tools/miri/src/shims/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4444
"the program aborted execution".to_owned()
4545
))
4646
}
47-
_ => {},
47+
_ => {}
4848
}
4949

5050
// All remaining supported intrinsics have a return place.

src/tools/miri/test-cargo-miri/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ issue_rust_86261 = { path = "issue-rust-86261" }
2020

2121
[dev-dependencies]
2222
byteorder_2 = { package = "byteorder", version = "0.5" } # to test dev-dependencies behave as expected, with renaming
23-
serde_derive = "1.0" # not actually used, but exercises some unique code path (`--extern` .so file)
23+
# Not actually used, but exercises some unique code path (`--extern` .so file).
24+
# Pin a version without intransparent unreproducible binary blobs.
25+
serde_derive = "=1.0.152"
2426

2527
[build-dependencies]
2628
autocfg = "1"

0 commit comments

Comments
 (0)