Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,41 @@ jobs:
- name: rustdoc
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items

bootstrap:
name: bootstrap build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Deliberately skipping `./.github/workflows/setup` as we do our own setup
- name: Add cache for cargo
id: cache
uses: actions/cache@v4
with:
path: |
# Taken from <https://doc.rust-lang.org/nightly/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci>.
# Cache package/registry information
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
# Cache bootstrap downloads
../rust/build/cache
key: cargo-bootstrap-${{ hashFiles('rust-version') }}
restore-keys: cargo-bootstrap
- name: prepare build environment
run: |
MIRIDIR=$(pwd)
cd ..
# Bootstrap needs at least depth 2 to function.
git clone https://github.com/rust-lang/rust/ rust --depth 2 --revision $(cat "$MIRIDIR/rust-version")
cd rust
# Replace the in-tree Miri with the current version.
rm src/tools/miri -rf
ln -s "$MIRIDIR" src/tools/miri
- name: check build
run: |
cd ../rust # ./x does not seem to like being invoked from elsewhere
./x check miri

coverage:
name: coverage report
runs-on: ubuntu-latest
Expand All @@ -130,7 +165,7 @@ jobs:
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
# And they should be added below in `cron-fail-notify` as well.
conclusion:
needs: [test, style, coverage]
needs: [test, style, bootstrap, coverage]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
Expand Down Expand Up @@ -211,7 +246,7 @@ jobs:
cron-fail-notify:
name: cronjob failure notification
runs-on: ubuntu-latest
needs: [test, style, coverage]
needs: [test, style, bootstrap, coverage]
if: ${{ github.event_name == 'schedule' && failure() }}
steps:
# Send a Zulip notification
Expand Down
8 changes: 4 additions & 4 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ impl Command {
let new_commit = sh.read_file("rust-version")?.trim().to_owned();
let current_commit = {
let rustc_info = cmd!(sh, "rustc +miri --version -v").read();
if rustc_info.is_err() {
None
} else {
let metadata = rustc_version::version_meta_for(&rustc_info.unwrap())?;
if let Ok(rustc_info) = rustc_info {
let metadata = rustc_version::version_meta_for(&rustc_info)?;
Some(
metadata
.commit_hash
.ok_or_else(|| anyhow!("rustc metadata did not contain commit hash"))?,
)
} else {
None
}
};
// Check if we already are at that commit.
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 @@
3f1552a273e43e15f6ed240d00e1efdd6a53e65e
f6092f224d2b1774b31033f12d0bee626943b02f
6 changes: 3 additions & 3 deletions src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ pub(super) enum TransitionError {
ChildAccessForbidden(Permission),
/// A protector was triggered due to an invalid transition that loses
/// too much permissions.
/// For example, if a protected tag goes from `Active` to `Disabled` due
/// to a foreign write this will produce a `ProtectedDisabled(Active)`.
/// For example, if a protected tag goes from `Unique` to `Disabled` due
/// to a foreign write this will produce a `ProtectedDisabled(Unique)`.
/// This kind of error can only occur on foreign accesses.
ProtectedDisabled(Permission),
/// Cannot deallocate because some tag in the allocation is strongly protected.
Expand Down Expand Up @@ -504,7 +504,7 @@ impl DisplayFmt {
if let Some(perm) = perm {
format!(
"{ac}{st}",
ac = if perm.is_accessed() { self.accessed.yes } else { self.accessed.no },
ac = if perm.accessed() { self.accessed.yes } else { self.accessed.no },
st = perm.permission().short_name(),
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use super::tree::AccessRelatedness;
/// "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.
///
/// Note that we derive Ord and PartialOrd, so the order in which variants are listed below matters:
/// None < Read < Write. Do not change that order. See the `test_order` test.
/// None < Read < Write (weaker to stronger). Do not change that order. See the `test_order` test.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)]
pub enum IdempotentForeignAccess {
#[default]
Expand Down
28 changes: 5 additions & 23 deletions src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,24 +294,6 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
return interp_ok(Some(Provenance::Concrete { alloc_id, tag: new_tag }));
}

let span = this.machine.current_span();

// When adding a new node, the SIFA of its parents needs to be updated, potentially across
// the entire memory range. For the parts that are being accessed below, the access itself
// trivially takes care of that. However, we have to do some more work to also deal with the
// parts that are not being accessed. Specifically what we do is that we call
// `update_last_accessed_after_retag` on the SIFA of the permission set for the part of
// memory outside `perm_map` -- so that part is definitely taken care of. The remaining
// concern is the part of memory that is in the range of `perms_map`, but not accessed
// below. There we have two cases:
// * If the type is `!Freeze`, then the non-accessed part uses `nonfreeze_perm`, so the
// `nonfreeze_perm` initialized parts are also fine. We enforce the `freeze_perm` parts to
// be accessed via the assert below, and thus everything is taken care of.
// * If the type is `Freeze`, then `freeze_perm` is used everywhere (both inside and outside
// the initial range), and we update everything to have the `freeze_perm`'s SIFA, so there
// are no issues. (And this assert below is not actually needed in this case).
assert!(new_perm.freeze_access);

let protected = new_perm.protector.is_some();
let precise_interior_mut = this
.machine
Expand All @@ -337,7 +319,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
LocationState::new_non_accessed(perm, sifa)
}
};
let perms_map = if !precise_interior_mut {
let inside_perms = if !precise_interior_mut {
// For `!Freeze` types, just pretend the entire thing is an `UnsafeCell`.
let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
let state = loc_state(ty_is_freeze);
Expand All @@ -364,8 +346,8 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let alloc_extra = this.get_alloc_extra(alloc_id)?;
let mut tree_borrows = alloc_extra.borrow_tracker_tb().borrow_mut();

for (perm_range, perm) in perms_map.iter_all() {
if perm.is_accessed() {
for (perm_range, perm) in inside_perms.iter_all() {
if perm.accessed() {
// Some reborrows incur a read access to the parent.
// Adjust range to be relative to allocation start (rather than to `place`).
let range_in_alloc = AllocRange {
Expand Down Expand Up @@ -401,10 +383,10 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
base_offset,
orig_tag,
new_tag,
perms_map,
inside_perms,
new_perm.outside_perm,
protected,
span,
this.machine.current_span(),
)?;
drop(tree_borrows);

Expand Down
Loading
Loading