Skip to content

update Miri #113488

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

Merged
merged 49 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ccb3328
Bashy Mc Bashface
oli-obk Jun 29, 2023
2039e7c
Checking for a cached value without having a cache is useless
oli-obk Jun 29, 2023
d061edd
Auto merge of #2947 - oli-obk:gha_mk_pr, r=RalfJung
bors Jun 29, 2023
5fa7403
cronjob auto-PR: make sure we are on a branch
RalfJung Jul 2, 2023
9e49f53
Auto merge of #2948 - RalfJung:cron, r=RalfJung
bors Jul 2, 2023
04db677
cronjob auto-PR: fetch more of the history
RalfJung Jul 2, 2023
7adf8dd
CI cleanup
RalfJung Jul 2, 2023
918f393
Auto merge of #2949 - RalfJung:cron, r=RalfJung
bors Jul 2, 2023
cc4670f
cargo-miri: better error message when RUSTC is not set
icewind1991 Jul 2, 2023
f2ce230
cron auto-PR: need to set upstream branch
RalfJung Jul 2, 2023
a6eb25a
Auto merge of #2951 - rust-lang:cron, r=RalfJung
bors Jul 2, 2023
7d12d2f
Auto merge of #2950 - icewind1991:cargo-miri-rustc-error, r=RalfJung
bors Jul 2, 2023
32168b7
cronjob auto-PR: try to fix setting the remote branch
RalfJung Jul 2, 2023
0bf13a4
Auto merge of #2952 - RalfJung:cron, r=RalfJung
bors Jul 2, 2023
2c5e076
sadly 'gh' doesnt support all git upstream branch configs
RalfJung Jul 2, 2023
f037471
Auto merge of #2953 - RalfJung:cron, r=RalfJung
bors Jul 2, 2023
4c7fbf8
more CI yml cleanup
RalfJung Jul 2, 2023
352180b
can't seem to avoid repeating the branch name...
RalfJung Jul 2, 2023
7d63d70
Auto merge of #2954 - RalfJung:cron, r=RalfJung
bors Jul 2, 2023
17e17e1
Preparing for merge from rustc
Jul 3, 2023
1505dd8
Merge from rustc
Jul 3, 2023
707afc3
fmt
Jul 3, 2023
6a21b2d
Silence clippy on FIXME'd code and fix the new lints otherwise
oli-obk Jul 3, 2023
a8b6ec1
Auto merge of #2955 - rust-lang:rustup2023-07-03, r=oli-obk
bors Jul 3, 2023
46c1e61
send link to PR to Zulip
RalfJung Jul 3, 2023
4951d5f
remove outdated comment
RalfJung Jul 3, 2023
a68afa2
vec tets: ensure pointer is still writeable
RalfJung Jul 3, 2023
89c2596
Auto merge of #2959 - RalfJung:vectest, r=RalfJung
bors Jul 3, 2023
2b3fae1
Auto merge of #2957 - RalfJung:zulip, r=oli-obk
bors Jul 4, 2023
812f9b2
better error on missing #[start]
RalfJung Jul 4, 2023
da98baa
Restore test filtering by substring.
oli-obk Jul 4, 2023
8fa4894
Auto merge of #2963 - RalfJung:start, r=RalfJung
bors Jul 4, 2023
7591c51
Auto merge of #2960 - oli-obk:run_filter, r=oli-obk
bors Jul 4, 2023
a4b7e14
C "memcpy" shim: ensure the pointers are valid
RalfJung Jul 5, 2023
a811ada
Ignore test on apple
oli-obk Jul 6, 2023
c8b3992
Auto merge of #2968 - RalfJung:memcpy, r=RalfJung
bors Jul 6, 2023
822feaa
Stop parsing ui_test annotations in `run-dep` mode
oli-obk Jul 6, 2023
a5286fc
Preparing for merge from rustc
Jul 7, 2023
b13a9fa
Merge from rustc
Jul 7, 2023
536c910
fmt
Jul 7, 2023
fa6cf3f
Auto merge of #2970 - rust-lang:rustup2023-07-07, r=oli-obk
bors Jul 7, 2023
813b56b
Silence all the boilerplate around `./miri run` and `./miri run-dep`
oli-obk Jul 7, 2023
48fe0df
Remove a now-useless flag
oli-obk Jul 7, 2023
c6f5b5f
MIRIFLAGS are already passed in the `./miri` wrapper
oli-obk Jul 7, 2023
2323ecb
Auto merge of #2969 - oli-obk:run-dep, r=RalfJung
bors Jul 7, 2023
2c3cf5a
Preparing for merge from rustc
Jul 8, 2023
c182669
Merge from rustc
Jul 8, 2023
dfe0d21
Auto merge of #2971 - rust-lang:rustup2023-07-08, r=RalfJung
bors Jul 8, 2023
9ed4669
update lockfile
RalfJung Jul 8, 2023
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5030,9 +5030,9 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"

[[package]]
name = "ui_test"
version = "0.11.6"
version = "0.11.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1"
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
dependencies = [
"bstr",
"cargo-platform",
Expand Down
47 changes: 27 additions & 20 deletions src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
env:
CARGO_UNSTABLE_SPARSE_REGISTRY: 'true'

defaults:
run:
shell: bash

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -59,12 +63,9 @@ jobs:

- name: Install rustup-toolchain-install-master
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cargo install -f rustup-toolchain-install-master
run: cargo install -f rustup-toolchain-install-master

- name: Install "master" toolchain
shell: bash
run: |
if [[ ${{ github.event_name }} == 'schedule' ]]; then
echo "Building against latest rustc git version"
Expand All @@ -79,7 +80,7 @@ jobs:
cargo -V

- name: Test
run: bash ./ci.sh
run: ./ci.sh

style:
name: style checks
Expand Down Expand Up @@ -111,14 +112,10 @@ jobs:

- name: Install rustup-toolchain-install-master
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cargo install -f rustup-toolchain-install-master
run: cargo install -f rustup-toolchain-install-master

- name: Install "master" toolchain
shell: bash
run: |
./miri toolchain
run: ./miri toolchain

- name: Show Rust version
run: |
Expand All @@ -138,7 +135,6 @@ jobs:
# workflow is successful listening to webhooks only.
#
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
# (`fmt` is deliberately not listed, we want bors to ignore it.)
end-success:
name: bors build finished
runs-on: ubuntu-latest
Expand Down Expand Up @@ -166,12 +162,12 @@ jobs:
- name: Install zulip-send
run: pip3 install zulip
- name: Send Zulip notification
shell: bash
env:
ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
run: |
~/.local/bin/zulip-send --stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
--message 'Dear @*T-miri*,

It would appear that the [Miri cron job build]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"') failed.
Expand All @@ -183,9 +179,12 @@ jobs:

Thanks in advance!
Sincerely,
The Miri Cronjobs Bot' \
--user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com
The Miri Cronjobs Bot'

# Attempt to auto-sync with rustc
- uses: actions/checkout@v3
with:
fetch-depth: 256 # get a bit more of the history
- name: install josh-proxy
run: cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r22.12.06
- name: start josh-proxy
Expand All @@ -196,16 +195,24 @@ jobs:
git config --global user.email '[email protected]'
- name: get changes from rustc
run: ./miri rustc-pull
- name: Install rustup-toolchain-install-master
run: cargo install -f rustup-toolchain-install-master
- name: format changes (if any)
run: |
./miri toolchain
./miri fmt --check || (./miri fmt && git commit -am "fmt")
- name: Push changes to a branch
run: |
git switch -c "rustup$(date -u +%Y-%m)"
git push
BRANCH="rustup$(date -u +%Y-%m-%d)"
git switch -c $BRANCH
git push -u origin $BRANCH
- name: Create Pull Request
run: gh pr create -B master --title 'Automatic sync from rustc' --body ''
run: |
PR=$(gh pr create -B master --title 'Automatic sync from rustc' --body '')
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
--message "A PR doing a rustc-pull [has been automatically created]($PR) for your convenience."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
4 changes: 2 additions & 2 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,9 @@ dependencies = [

[[package]]
name = "ui_test"
version = "0.11.6"
version = "0.11.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24a2e70adc9d18b9b4dd80ea57aeec447103c6fbb354a07c080adad451c645e1"
checksum = "c21899b59f53717dfad29e4f46e5b21a200a1b6888ab86532a07cfc8b48dd78c"
dependencies = [
"bstr",
"cargo-platform",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ libloading = "0.7"

[dev-dependencies]
colored = "2"
ui_test = "0.11.6"
ui_test = "0.11.7"
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"] }
Expand Down
6 changes: 5 additions & 1 deletion src/tools/miri/cargo-miri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ fn main() {
match first.as_str() {
"miri" => phase_cargo_miri(args),
"runner" => phase_runner(args, RunnerPhase::Cargo),
arg if arg == env::var("RUSTC").unwrap() => {
arg if arg == env::var("RUSTC").unwrap_or_else(|_| {
show_error!(
"`cargo-miri` called without RUSTC set; please only invoke this binary through `cargo miri`"
)
}) => {
// If the first arg is equal to the RUSTC env variable (which should be set at this
// point), then we need to behave as rustc. This is the somewhat counter-intuitive
// behavior of having both RUSTC and RUSTC_WRAPPER set
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/cargo-miri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub enum MiriCommand {
pub fn escape_for_toml(s: &str) -> String {
// We want to surround this string in quotes `"`. So we first escape all quotes,
// and also all backslashes (that are used to escape quotes).
let s = s.replace('\\', r#"\\"#).replace('"', r#"\""#);
let s = s.replace('\\', r"\\").replace('"', r#"\""#);
format!("\"{s}\"")
}

Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn exec(mut cmd: Command) -> ! {
{
use std::os::unix::process::CommandExt;
let error = cmd.exec();
Err(error).expect("failed to run command")
panic!("failed to run command: {error}")
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/tools/miri/miri
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ rustc-pull)
git commit rust-version -m "Preparing for merge from rustc" || (echo "FAILED to commit rust-version file, something went wrong"; exit 1)
# Fetch given rustc commit and note down which one that was
git fetch http://localhost:8000/rust-lang/rust.git@$FETCH_COMMIT$JOSH_FILTER.git || (echo "FAILED to fetch new commits, something went wrong"; exit 1)
git merge FETCH_HEAD --no-ff -m "Merge from rustc" || (echo "FAILED to merge new commits, something went wrong"; exit 1)
git merge FETCH_HEAD --no-ff -m "Merge from rustc" || (echo "FAILED to merge new commits ($(git rev-parse FETCH_HEAD)), something went wrong"; exit 1)
exit 0
;;
rustc-push)
Expand Down Expand Up @@ -325,6 +325,7 @@ run|run-dep)
MIRIFLAGS="$MIRIFLAGS --target $MIRI_TEST_TARGET"
fi

CARGO="$CARGO --quiet"
# First build and get a sysroot.
$CARGO build $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml
find_sysroot
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 @@
75726cae37317c7262b69d3e9fd11a3496a88d04
d4096e0412ac5de785d739a0aa2b1c1c7b9d3b7d
2 changes: 1 addition & 1 deletion src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
if tcx.sess.compile_status().is_err() {
tcx.sess.fatal("miri cannot be run on programs that fail compilation");
}
;

init_late_loggers(handler, tcx);
if !tcx.sess.crate_types().contains(&CrateType::Executable) {
tcx.sess.fatal("miri only makes sense on bin crates");
Expand Down
29 changes: 19 additions & 10 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ impl AllocHistory {
impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
pub fn start_grant(&mut self, perm: Permission) {
let Operation::Retag(op) = &mut self.operation else {
unreachable!("start_grant must only be called during a retag, this is: {:?}", self.operation)
unreachable!(
"start_grant must only be called during a retag, this is: {:?}",
self.operation
)
};
op.permission = Some(perm);

Expand Down Expand Up @@ -286,7 +289,8 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
tag: BorTag,
protector_tag: Option<BorTag>,
) -> Option<TagHistory> {
let Some(created) = self.history
let Some(created) = self
.history
.creations
.iter()
.rev()
Expand Down Expand Up @@ -315,22 +319,27 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
None
}
})
}).or_else(|| {
})
.or_else(|| {
// If we didn't find a retag that created this tag, it might be the base tag of
// this allocation.
if self.history.base.0.tag() == tag {
Some((
format!("{tag:?} was created here, as the base tag for {:?}", self.history.id),
self.history.base.1.data()
format!(
"{tag:?} was created here, as the base tag for {:?}",
self.history.id
),
self.history.base.1.data(),
))
} else {
None
}
}) else {
// But if we don't have a creation event, this is related to a wildcard, and there
// is really nothing we can do to help.
return None;
};
})
else {
// But if we don't have a creation event, this is related to a wildcard, and there
// is really nothing we can do to help.
return None;
};

let invalidated = self.history.invalidations.iter().rev().find_map(|event| {
if event.tag == tag { Some(event.generate_diagnostic()) } else { None }
Expand Down
9 changes: 6 additions & 3 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,15 @@ impl<'tcx> Stack {
.find_granting(AccessKind::Write, derived_from, exposed_tags)
.map_err(|()| dcx.grant_error(self))?;

let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from) else {
let (Some(granting_idx), ProvenanceExtra::Concrete(_)) = (granting_idx, derived_from)
else {
// The parent is a wildcard pointer or matched the unknown bottom.
// This is approximate. Nobody knows what happened, so forget everything.
// The new thing is SRW anyway, so we cannot push it "on top of the unknown part"
// (for all we know, it might join an SRW group inside the unknown).
trace!("reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown");
trace!(
"reborrow: forgetting stack entirely due to SharedReadWrite reborrow from wildcard or unknown"
);
self.set_unknown_bottom(global.next_ptr_tag);
return Ok(());
};
Expand Down Expand Up @@ -1008,7 +1011,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

// We have to turn the place into a pointer to use the existing code.
// (The pointer type does not matter, so we use a raw pointer.)
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx,return_place.layout.ty))?;
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
// Reborrow it. With protection! That is part of the point.
let new_perm = NewPermission::Uniform {
Expand Down
26 changes: 13 additions & 13 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,19 @@ impl<'tcx> Stack {
let ProvenanceExtra::Concrete(tag) = tag else {
// Handle the wildcard case.
// Go search the stack for an exposed tag.
if let Some(idx) =
self.borrows
.iter()
.enumerate() // we also need to know *where* in the stack
.rev() // search top-to-bottom
.find_map(|(idx, item)| {
// If the item fits and *might* be this wildcard, use it.
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
Some(idx)
} else {
None
}
})
if let Some(idx) = self
.borrows
.iter()
.enumerate() // we also need to know *where* in the stack
.rev() // search top-to-bottom
.find_map(|(idx, item)| {
// If the item fits and *might* be this wildcard, use it.
if item.perm().grants(access) && exposed_tags.contains(&item.tag()) {
Some(idx)
} else {
None
}
})
{
return Ok(Some(idx));
}
Expand Down
8 changes: 6 additions & 2 deletions src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,13 @@ impl DisplayRepr {
extraction_aux(tree, tree.root, show_unnamed, &mut v);
let Some(root) = v.pop() else {
if show_unnamed {
unreachable!("This allocation contains no tags, not even a root. This should not happen.");
unreachable!(
"This allocation contains no tags, not even a root. This should not happen."
);
}
eprintln!("This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags.");
eprintln!(
"This allocation does not contain named tags. Use `miri_print_borrow_state(_, true)` to also print unnamed tags."
);
return None;
};
assert!(v.is_empty());
Expand Down
6 changes: 4 additions & 2 deletions src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
ptr_size.bytes()
);

let Some(new_perm) = new_perm else { return Ok(Some((alloc_id, orig_tag))); };
let Some(new_perm) = new_perm else {
return Ok(Some((alloc_id, orig_tag)));
};

if let Some(protect) = new_perm.protector {
// We register the protection in two different places.
Expand Down Expand Up @@ -509,7 +511,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

// We have to turn the place into a pointer to use the existing code.
// (The pointer type does not matter, so we use a raw pointer.)
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx,return_place.layout.ty))?;
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
// Reborrow it. With protection! That is part of the point.
// FIXME: do we truly want a 2phase borrow here?
Expand Down
Loading