Skip to content
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

update Miri #106121

Merged
merged 45 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
20a4c73
add graceful shim for the custom `O_TMPFILE` linux file opening flag …
Pointerbender Dec 8, 2022
4e9f839
Preparing for merge from rustc
RalfJung Dec 9, 2022
aab3bce
Merge from rustc
RalfJung Dec 9, 2022
3ba51ac
fmt and clippy
RalfJung Dec 9, 2022
816ec1b
Auto merge of #2718 - Pointerbender:o_tmpfile_flag, r=oli-obk
bors Dec 9, 2022
17b5fda
Auto merge of #2719 - RalfJung:rustup, r=RalfJung
bors Dec 9, 2022
30e4359
Preparing for merge from rustc
RalfJung Dec 11, 2022
f25d8a6
Merge from rustc
RalfJung Dec 11, 2022
6d4dd6e
Auto merge of #2723 - RalfJung:rustup, r=RalfJung
bors Dec 11, 2022
7949f21
add support for variable page sizes to miri
nia-e Dec 9, 2022
f2ae9e5
Auto merge of #2721 - a-b-c-1-2-3:fix-pagesize, r=RalfJung
bors Dec 11, 2022
a4b966a
add provenance-related test
RalfJung Dec 11, 2022
0876519
Auto merge of #2726 - RalfJung:provenance-test, r=RalfJung
bors Dec 11, 2022
c905ef4
make flag checks reobust against multi-bit flags
RalfJung Dec 12, 2022
f0bb7c7
make eval_libc functions ICE on any problem
RalfJung Dec 12, 2022
b8f972f
Auto merge of #2727 - RalfJung:flags-and-libc, r=RalfJung
bors Dec 12, 2022
c19ca08
expose host-to-target path conversion to interpreted program
RalfJung Dec 11, 2022
a66780b
More host/target path conversion tests:
RalfJung Dec 11, 2022
802987d
make unix path handling on Windows hosts preserve absoluteness
RalfJung Dec 11, 2022
2949702
Windows targets: make sure current_dir is absolute
RalfJung Dec 11, 2022
8b19af0
Auto merge of #2725 - RalfJung:host-to-target-path, r=RalfJung
bors Dec 12, 2022
1b51f37
implement minimal epoll_create1 shim
DebugSteven Jul 11, 2022
7893132
Auto merge of #2357 - DebugSteven:epoll_create1-shim, r=oli-obk
bors Dec 14, 2022
33e5b95
Preparing for merge from rustc
RalfJung Dec 16, 2022
3d67703
Merge from rustc
RalfJung Dec 16, 2022
39bb865
fmt
RalfJung Dec 16, 2022
e82a604
Auto merge of #2731 - RalfJung:rustup, r=RalfJung
bors Dec 16, 2022
d1184ae
Include a Span in VClock
saethlin Oct 31, 2022
d2e1c37
Fix span management
saethlin Dec 21, 2022
749b2b0
Re-enable the VClock ordering tests
saethlin Dec 21, 2022
90d8fc6
update josh onstructions
RalfJung Dec 21, 2022
5b64c91
Auto merge of #2736 - RalfJung:josh, r=oli-obk
bors Dec 21, 2022
c2f459c
Clean up implementation, deduplicate in errors
saethlin Dec 22, 2022
a2e09ba
Fix phrasing
saethlin Dec 22, 2022
f4165be
Add a (1) and (2) to the data race errors
saethlin Dec 22, 2022
19422fc
attempt to clarify what the backtrace belongs to when there could be …
RalfJung Dec 23, 2022
81fe37a
Mention and number the components of a race in the order the interpre…
saethlin Dec 23, 2022
245357f
Auto merge of #2646 - saethlin:data-race-spans, r=RalfJung
bors Dec 24, 2022
0c14ad4
Preparing for merge from rustc
RalfJung Dec 24, 2022
9c01e9f
Merge from rustc
RalfJung Dec 24, 2022
e52e0d8
fix warnings
RalfJung Dec 24, 2022
d23554f
Auto merge of #2738 - RalfJung:rustup, r=RalfJung
bors Dec 24, 2022
fed7e2c
use cargo-install to install josh-proxy
RalfJung Dec 25, 2022
92b6562
enable some warnings that rustc bootstrap enables
RalfJung Dec 25, 2022
d8b48d4
Auto merge of #2739 - RalfJung:misc, r=RalfJung
bors Dec 25, 2022
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
12 changes: 6 additions & 6 deletions src/tools/miri/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ You can also directly run Miri on a Rust source file:

## Advanced topic: Syncing with the rustc repo

We use the [`josh` proxy](https://github.com/josh-project/josh) to transmit
changes between the rustc and Miri repositories. For now, the latest git version
of josh needs to be built from source. This downloads and runs josh:
We use the [`josh` proxy](https://github.com/josh-project/josh) to transmit changes between the
rustc and Miri repositories.

```sh
git clone https://github.com/josh-project/josh
cd josh
cargo run --release -p josh-proxy -- --local=local --remote=https://github.com --no-background
cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r22.12.06
josh-proxy --local=$HOME/.cache/josh --remote=https://github.com --no-background
```

This uses a directory `$HOME/.cache/josh` as a cache, to speed up repeated pulling/pushing.

### Importing changes from the rustc repo

Josh needs to be running, as described above.
Expand Down
17 changes: 17 additions & 0 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ to Miri failing to detect cases of undefined behavior in a program.
* `-Zmiri-track-weak-memory-loads` shows a backtrace when weak memory emulation returns an outdated
value from a load. This can help diagnose problems that disappear under
`-Zmiri-disable-weak-memory-emulation`.
* `-Zmiri-force-page-size=<num>` overrides the default page size for an architecture, in multiples of 1k.
`4` is default for most targets. This value should always be a power of 2 and nonzero.

[function ABI]: https://doc.rust-lang.org/reference/items/functions.html#extern-function-qualifier

Expand Down Expand Up @@ -574,6 +576,21 @@ extern "Rust" {

/// Miri-provided extern function to deallocate memory.
fn miri_dealloc(ptr: *mut u8, size: usize, align: usize);

/// Convert a path from the host Miri runs on to the target Miri interprets.
/// Performs conversion of path separators as needed.
///
/// Usually Miri performs this kind of conversion automatically. However, manual conversion
/// might be necessary when reading an environment variable that was set on the host
/// (such as TMPDIR) and using it as a target path.
///
/// Only works with isolation disabled.
///
/// `in` must point to a null-terminated string, and will be read as the input host path.
/// `out` must point to at least `out_size` many bytes, and the result will be stored there
/// with a null terminator.
/// Returns 0 if the `out` buffer was large enough, and the required size otherwise.
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/miri
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ if [ -z "$CARGO_PROFILE_DEV_OPT_LEVEL" ]; then
export CARGO_PROFILE_DEV_OPT_LEVEL=2
fi
# Enable rustc-specific lints (ignored without `-Zunstable-options`).
export RUSTFLAGS="-Zunstable-options -Wrustc::internal $RUSTFLAGS"
export RUSTFLAGS="-Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros $RUSTFLAGS"
# We set the rpath so that Miri finds the private rustc libraries it needs.
export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR $RUSTFLAGS"

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 @@
203c8765ea33c65d888febe0e8219c4bb11b0d89
4f4d0586ad20c66a16d547581ca379beafece93a
12 changes: 12 additions & 0 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,18 @@ fn main() {
};

miri_config.num_cpus = num_cpus;
} else if let Some(param) = arg.strip_prefix("-Zmiri-force-page-size=") {
let page_size = match param.parse::<u64>() {
Ok(i) =>
if i.is_power_of_two() {
i * 1024
} else {
show_error!("-Zmiri-force-page-size requires a power of 2: {}", i)
},
Err(err) => show_error!("-Zmiri-force-page-size requires a `u64`: {}", err),
};

miri_config.page_size = Some(page_size);
} else {
// Forward to rustc.
rustc_args.push(arg);
Expand Down
12 changes: 10 additions & 2 deletions src/tools/miri/src/borrow_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,23 @@ impl GlobalStateInner {

impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
fn retag_ptr_value(&mut self, kind: RetagKind, val: &ImmTy<'tcx, Provenance>) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
fn retag_ptr_value(
&mut self,
kind: RetagKind,
val: &ImmTy<'tcx, Provenance>,
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
let this = self.eval_context_mut();
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_retag_ptr_value(kind, val),
}
}

fn retag_place_contents(&mut self, kind: RetagKind, place: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> {
fn retag_place_contents(
&mut self,
kind: RetagKind,
place: &PlaceTy<'tcx, Provenance>,
) -> InterpResult<'tcx> {
let this = self.eval_context_mut();
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
Operation::Retag(RetagOp { orig_tag, permission, new_tag, .. }) => {
let permission = permission
.expect("start_grant should set the current permission before popping a tag");
format!(" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})")
format!(
" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})"
)
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use rustc_middle::mir::{Mutability, RetagKind};
use rustc_middle::ty::{
self,
layout::{HasParamEnv, LayoutOf},
Ty,
};
use rustc_target::abi::{Abi, Size};

Expand Down Expand Up @@ -64,7 +65,7 @@ impl NewPermission {
/// A key function: determine the permissions to grant at a retag for the given kind of
/// reference/pointer.
fn from_ref_ty<'tcx>(
ty: ty::Ty<'tcx>,
ty: Ty<'tcx>,
kind: RetagKind,
cx: &crate::MiriInterpCx<'_, 'tcx>,
) -> Self {
Expand Down Expand Up @@ -864,7 +865,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
RetagKind::FnEntry => unreachable!(),
RetagKind::Raw | RetagKind::Default => RetagCause::Normal,
};
this.sb_retag_reference(&val, new_perm, retag_cause)
this.sb_retag_reference(val, new_perm, retag_cause)
}

fn sb_retag_place_contents(
Expand Down
Loading