Skip to content

Commit ba876d0

Browse files
borsMuscraft
authored andcommitted
Auto merge of rust-lang#146931 - RalfJung:miri, r=RalfJung
miri subtree update Subtree update of `miri` to rust-lang/miri@f6466ce. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
2 parents bbd7d52 + 483dec0 commit ba876d0

36 files changed

+370
-444
lines changed

src/tools/miri/.github/workflows/ci.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,41 @@ jobs:
117117
- name: rustdoc
118118
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items
119119

120+
bootstrap:
121+
name: bootstrap build
122+
runs-on: ubuntu-latest
123+
steps:
124+
- uses: actions/checkout@v4
125+
# Deliberately skipping `./.github/workflows/setup` as we do our own setup
126+
- name: Add cache for cargo
127+
id: cache
128+
uses: actions/cache@v4
129+
with:
130+
path: |
131+
# Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
132+
# Cache package/registry information
133+
~/.cargo/registry/index
134+
~/.cargo/registry/cache
135+
~/.cargo/git/db
136+
# Cache bootstrap downloads
137+
../rust/build/cache
138+
key: cargo-bootstrap-${{ hashFiles('rust-version') }}
139+
restore-keys: cargo-bootstrap
140+
- name: prepare build environment
141+
run: |
142+
MIRIDIR=$(pwd)
143+
cd ..
144+
# Bootstrap needs at least depth 2 to function.
145+
git clone https://github.com/rust-lang/rust/ rust --depth 2 --revision $(cat "$MIRIDIR/rust-version")
146+
cd rust
147+
# Replace the in-tree Miri with the current version.
148+
rm src/tools/miri -rf
149+
ln -s "$MIRIDIR" src/tools/miri
150+
- name: check build
151+
run: |
152+
cd ../rust # ./x does not seem to like being invoked from elsewhere
153+
./x check miri
154+
120155
coverage:
121156
name: coverage report
122157
runs-on: ubuntu-latest
@@ -130,7 +165,7 @@ jobs:
130165
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
131166
# And they should be added below in `cron-fail-notify` as well.
132167
conclusion:
133-
needs: [test, style, coverage]
168+
needs: [test, style, bootstrap, coverage]
134169
# We need to ensure this job does *not* get skipped if its dependencies fail,
135170
# because a skipped job is considered a success by GitHub. So we have to
136171
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
@@ -211,7 +246,7 @@ jobs:
211246
cron-fail-notify:
212247
name: cronjob failure notification
213248
runs-on: ubuntu-latest
214-
needs: [test, style, coverage]
249+
needs: [test, style, bootstrap, coverage]
215250
if: ${{ github.event_name == 'schedule' && failure() }}
216251
steps:
217252
# Send a Zulip notification

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ impl Command {
130130
let new_commit = sh.read_file("rust-version")?.trim().to_owned();
131131
let current_commit = {
132132
let rustc_info = cmd!(sh, "rustc +miri --version -v").read();
133-
if rustc_info.is_err() {
134-
None
135-
} else {
136-
let metadata = rustc_version::version_meta_for(&rustc_info.unwrap())?;
133+
if let Ok(rustc_info) = rustc_info {
134+
let metadata = rustc_version::version_meta_for(&rustc_info)?;
137135
Some(
138136
metadata
139137
.commit_hash
140138
.ok_or_else(|| anyhow!("rustc metadata did not contain commit hash"))?,
141139
)
140+
} else {
141+
None
142142
}
143143
};
144144
// Check if we already are at that commit.

src/tools/miri/rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3f1552a273e43e15f6ed240d00e1efdd6a53e65e
1+
f6092f224d2b1774b31033f12d0bee626943b02f

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ pub(super) enum TransitionError {
244244
ChildAccessForbidden(Permission),
245245
/// A protector was triggered due to an invalid transition that loses
246246
/// too much permissions.
247-
/// For example, if a protected tag goes from `Active` to `Disabled` due
248-
/// to a foreign write this will produce a `ProtectedDisabled(Active)`.
247+
/// For example, if a protected tag goes from `Unique` to `Disabled` due
248+
/// to a foreign write this will produce a `ProtectedDisabled(Unique)`.
249249
/// This kind of error can only occur on foreign accesses.
250250
ProtectedDisabled(Permission),
251251
/// Cannot deallocate because some tag in the allocation is strongly protected.
@@ -504,7 +504,7 @@ impl DisplayFmt {
504504
if let Some(perm) = perm {
505505
format!(
506506
"{ac}{st}",
507-
ac = if perm.is_accessed() { self.accessed.yes } else { self.accessed.no },
507+
ac = if perm.accessed() { self.accessed.yes } else { self.accessed.no },
508508
st = perm.permission().short_name(),
509509
)
510510
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use super::tree::AccessRelatedness;
2424
/// "manually" reset the parent's SIFA to be at least as strong as the new child's. This is accomplished with the `ensure_no_stronger_than` method.
2525
///
2626
/// Note that we derive Ord and PartialOrd, so the order in which variants are listed below matters:
27-
/// None < Read < Write. Do not change that order. See the `test_order` test.
27+
/// None < Read < Write (weaker to stronger). Do not change that order. See the `test_order` test.
2828
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)]
2929
pub enum IdempotentForeignAccess {
3030
#[default]

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -294,24 +294,6 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
294294
return interp_ok(Some(Provenance::Concrete { alloc_id, tag: new_tag }));
295295
}
296296

297-
let span = this.machine.current_span();
298-
299-
// When adding a new node, the SIFA of its parents needs to be updated, potentially across
300-
// the entire memory range. For the parts that are being accessed below, the access itself
301-
// trivially takes care of that. However, we have to do some more work to also deal with the
302-
// parts that are not being accessed. Specifically what we do is that we call
303-
// `update_last_accessed_after_retag` on the SIFA of the permission set for the part of
304-
// memory outside `perm_map` -- so that part is definitely taken care of. The remaining
305-
// concern is the part of memory that is in the range of `perms_map`, but not accessed
306-
// below. There we have two cases:
307-
// * If the type is `!Freeze`, then the non-accessed part uses `nonfreeze_perm`, so the
308-
// `nonfreeze_perm` initialized parts are also fine. We enforce the `freeze_perm` parts to
309-
// be accessed via the assert below, and thus everything is taken care of.
310-
// * If the type is `Freeze`, then `freeze_perm` is used everywhere (both inside and outside
311-
// the initial range), and we update everything to have the `freeze_perm`'s SIFA, so there
312-
// are no issues. (And this assert below is not actually needed in this case).
313-
assert!(new_perm.freeze_access);
314-
315297
let protected = new_perm.protector.is_some();
316298
let precise_interior_mut = this
317299
.machine
@@ -337,7 +319,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
337319
LocationState::new_non_accessed(perm, sifa)
338320
}
339321
};
340-
let perms_map = if !precise_interior_mut {
322+
let inside_perms = if !precise_interior_mut {
341323
// For `!Freeze` types, just pretend the entire thing is an `UnsafeCell`.
342324
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
343325
let state = loc_state(ty_is_freeze);
@@ -364,8 +346,8 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
364346
let alloc_extra = this.get_alloc_extra(alloc_id)?;
365347
let mut tree_borrows = alloc_extra.borrow_tracker_tb().borrow_mut();
366348

367-
for (perm_range, perm) in perms_map.iter_all() {
368-
if perm.is_accessed() {
349+
for (perm_range, perm) in inside_perms.iter_all() {
350+
if perm.accessed() {
369351
// Some reborrows incur a read access to the parent.
370352
// Adjust range to be relative to allocation start (rather than to `place`).
371353
let range_in_alloc = AllocRange {
@@ -401,10 +383,10 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
401383
base_offset,
402384
orig_tag,
403385
new_tag,
404-
perms_map,
386+
inside_perms,
405387
new_perm.outside_perm,
406388
protected,
407-
span,
389+
this.machine.current_span(),
408390
)?;
409391
drop(tree_borrows);
410392

0 commit comments

Comments
 (0)