Skip to content

update Miri #115049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,7 @@ dependencies = [
"rand",
"regex",
"rustc_version",
"serde",
"smallvec",
"ui_test",
]
Expand Down
9 changes: 5 additions & 4 deletions src/tools/miri/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,17 @@ to `.vscode/settings.json` in your local Miri clone:
{
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./cargo-miri/Cargo.toml"
"Cargo.toml",
"cargo-miri/Cargo.toml",
"miri-script/Cargo.toml",
],
"rust-analyzer.checkOnSave.overrideCommand": [
"rust-analyzer.check.overrideCommand": [
"env",
"MIRI_AUTO_OPS=no",
"./miri",
"cargo",
"clippy", // make this `check` when working with a locally built rustc
"--message-format=json"
"--message-format=json",
],
// Contrary to what the name suggests, this also affects proc macros.
"rust-analyzer.cargo.buildScripts.overrideCommand": [
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ dependencies = [
"rand",
"regex",
"rustc_version",
"serde",
"smallvec",
"ui_test",
]
Expand Down
2 changes: 2 additions & 0 deletions src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ rustc_version = "0.4"
# Features chosen to match those required by env_logger, to avoid rebuilds
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }
lazy_static = "1.4.0"
# Pin a version of serde without intransparent unreproducible binary blobs.
serde = { version = "1.0, < 1.0.172", features = ["derive"] }

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)].
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ Some native rustc `-Z` flags are also very relevant for Miri:
Moreover, Miri recognizes some environment variables:

* `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup
should be skipped. If it is set to any value, they are skipped. This is used for avoiding infinite
recursion in `./miri` and to allow automated IDE actions to avoid the auto ops.
should be skipped. If it is set to `no`, they are skipped. This is used to allow automated IDE
actions to avoid the auto ops.
* `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during
Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri].
* `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra
Expand Down
3 changes: 2 additions & 1 deletion src/tools/miri/cargo-miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ rustc-build-sysroot = "0.4.1"

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

[build-dependencies]
rustc_tools_util = "0.3"
6 changes: 6 additions & 0 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl MiriEnv {

impl Command {
fn auto_actions() -> Result<()> {
if env::var_os("MIRI_AUTO_OPS").is_some_and(|x| x == "no") {
return Ok(());
}

let miri_dir = miri_dir()?;
let auto_everything = path!(miri_dir / ".auto-everything").exists();
let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists();
Expand All @@ -78,6 +82,7 @@ impl Command {
}

pub fn exec(self) -> Result<()> {
// First, and crucially only once, run the auto-actions -- but not for all commands.
match &self {
Command::Install { .. }
| Command::Build { .. }
Expand All @@ -93,6 +98,7 @@ impl Command {
| Command::Bench { .. }
| Command::RustcPush { .. } => {}
}
// Then run the actual command.
match self {
Command::Install { flags } => Self::install(flags),
Command::Build { flags } => Self::build(flags),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
656ee47db32e882fb02913f6204e09cc7a41a50e
c40cfcf0494ff7506e753e750adb00eeea839f9c
20 changes: 17 additions & 3 deletions src/tools/miri/src/borrow_tracker/tree_borrows/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,31 @@ mod transition {
fn foreign_read(state: PermissionPriv, protected: bool) -> Option<PermissionPriv> {
use Option::*;
Some(match state {
// Non-writeable states just ignore foreign reads.
non_writeable @ (Frozen | Disabled) => non_writeable,
// Writeable states are more tricky, and depend on whether things are protected.
// The inner data `ty_is_freeze` of `Reserved` is always irrelevant for Read
// accesses, since the data is not being mutated. Hence the `{ .. }`
res @ Reserved { .. } if !protected => res,
Reserved { .. } => Frozen, // protected reserved
res @ Reserved { .. } =>
if protected {
// Someone else read, make sure we won't write.
// We could make this `Disabled` but it doesn't look like we get anything out of that extra UB.
Frozen
} else {
// Before activation and without protectors, foreign reads are fine.
// That's the entire point of 2-phase borrows.
res
},
Active =>
if protected {
// We wrote, someone else reads -- that's bad.
// (If this is initialized, this move-to-protected will mean insta-UB.)
Disabled
} else {
// We don't want to disable here to allow read-read reordering: it is crucial
// that the foreign read does not invalidate future reads through this tag.
Frozen
},
non_writeable @ (Frozen | Disabled) => non_writeable,
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/shims/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
"the program aborted execution".to_owned()
))
}
_ => {},
_ => {}
}

// All remaining supported intrinsics have a return place.
Expand Down
4 changes: 3 additions & 1 deletion src/tools/miri/test-cargo-miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ issue_rust_86261 = { path = "issue-rust-86261" }

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

[build-dependencies]
autocfg = "1"
Expand Down