Skip to content

Commit 298d763

Browse files
committed
Auto merge of #106121 - RalfJung:miri, r=RalfJung
update Miri Noteworthy PRs: - rust-lang/miri#2357 - rust-lang/miri#2646 - rust-lang/miri#2718 - rust-lang/miri#2721 - rust-lang/miri#2725
2 parents 300aa90 + d8b48d4 commit 298d763

File tree

174 files changed

+1526
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+1526
-608
lines changed

src/tools/miri/CONTRIBUTING.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,16 @@ You can also directly run Miri on a Rust source file:
232232

233233
## Advanced topic: Syncing with the rustc repo
234234

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

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

243+
This uses a directory `$HOME/.cache/josh` as a cache, to speed up repeated pulling/pushing.
244+
245245
### Importing changes from the rustc repo
246246

247247
Josh needs to be running, as described above.

src/tools/miri/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ to Miri failing to detect cases of undefined behavior in a program.
399399
* `-Zmiri-track-weak-memory-loads` shows a backtrace when weak memory emulation returns an outdated
400400
value from a load. This can help diagnose problems that disappear under
401401
`-Zmiri-disable-weak-memory-emulation`.
402+
* `-Zmiri-force-page-size=<num>` overrides the default page size for an architecture, in multiples of 1k.
403+
`4` is default for most targets. This value should always be a power of 2 and nonzero.
402404

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

@@ -574,6 +576,21 @@ extern "Rust" {
574576

575577
/// Miri-provided extern function to deallocate memory.
576578
fn miri_dealloc(ptr: *mut u8, size: usize, align: usize);
579+
580+
/// Convert a path from the host Miri runs on to the target Miri interprets.
581+
/// Performs conversion of path separators as needed.
582+
///
583+
/// Usually Miri performs this kind of conversion automatically. However, manual conversion
584+
/// might be necessary when reading an environment variable that was set on the host
585+
/// (such as TMPDIR) and using it as a target path.
586+
///
587+
/// Only works with isolation disabled.
588+
///
589+
/// `in` must point to a null-terminated string, and will be read as the input host path.
590+
/// `out` must point to at least `out_size` many bytes, and the result will be stored there
591+
/// with a null terminator.
592+
/// Returns 0 if the `out` buffer was large enough, and the required size otherwise.
593+
fn miri_host_to_target_path(path: *const i8, out: *mut i8, out_size: usize) -> usize;
577594
}
578595
```
579596

src/tools/miri/miri

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ if [ -z "$CARGO_PROFILE_DEV_OPT_LEVEL" ]; then
243243
export CARGO_PROFILE_DEV_OPT_LEVEL=2
244244
fi
245245
# Enable rustc-specific lints (ignored without `-Zunstable-options`).
246-
export RUSTFLAGS="-Zunstable-options -Wrustc::internal $RUSTFLAGS"
246+
export RUSTFLAGS="-Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros $RUSTFLAGS"
247247
# We set the rpath so that Miri finds the private rustc libraries it needs.
248248
export RUSTFLAGS="-C link-args=-Wl,-rpath,$LIBDIR $RUSTFLAGS"
249249

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
203c8765ea33c65d888febe0e8219c4bb11b0d89
1+
4f4d0586ad20c66a16d547581ca379beafece93a

src/tools/miri/src/bin/miri.rs

+12
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,18 @@ fn main() {
512512
};
513513

514514
miri_config.num_cpus = num_cpus;
515+
} else if let Some(param) = arg.strip_prefix("-Zmiri-force-page-size=") {
516+
let page_size = match param.parse::<u64>() {
517+
Ok(i) =>
518+
if i.is_power_of_two() {
519+
i * 1024
520+
} else {
521+
show_error!("-Zmiri-force-page-size requires a power of 2: {}", i)
522+
},
523+
Err(err) => show_error!("-Zmiri-force-page-size requires a `u64`: {}", err),
524+
};
525+
526+
miri_config.page_size = Some(page_size);
515527
} else {
516528
// Forward to rustc.
517529
rustc_args.push(arg);

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,23 @@ impl GlobalStateInner {
264264

265265
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
266266
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
267-
fn retag_ptr_value(&mut self, kind: RetagKind, val: &ImmTy<'tcx, Provenance>) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
267+
fn retag_ptr_value(
268+
&mut self,
269+
kind: RetagKind,
270+
val: &ImmTy<'tcx, Provenance>,
271+
) -> InterpResult<'tcx, ImmTy<'tcx, Provenance>> {
268272
let this = self.eval_context_mut();
269273
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
270274
match method {
271275
BorrowTrackerMethod::StackedBorrows => this.sb_retag_ptr_value(kind, val),
272276
}
273277
}
274278

275-
fn retag_place_contents(&mut self, kind: RetagKind, place: &PlaceTy<'tcx, Provenance>) -> InterpResult<'tcx> {
279+
fn retag_place_contents(
280+
&mut self,
281+
kind: RetagKind,
282+
place: &PlaceTy<'tcx, Provenance>,
283+
) -> InterpResult<'tcx> {
276284
let this = self.eval_context_mut();
277285
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
278286
match method {

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
462462
Operation::Retag(RetagOp { orig_tag, permission, new_tag, .. }) => {
463463
let permission = permission
464464
.expect("start_grant should set the current permission before popping a tag");
465-
format!(" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})")
465+
format!(
466+
" due to {permission:?} retag from {orig_tag:?} (that retag created {new_tag:?})"
467+
)
466468
}
467469
};
468470

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_middle::mir::{Mutability, RetagKind};
1414
use rustc_middle::ty::{
1515
self,
1616
layout::{HasParamEnv, LayoutOf},
17+
Ty,
1718
};
1819
use rustc_target::abi::{Abi, Size};
1920

@@ -64,7 +65,7 @@ impl NewPermission {
6465
/// A key function: determine the permissions to grant at a retag for the given kind of
6566
/// reference/pointer.
6667
fn from_ref_ty<'tcx>(
67-
ty: ty::Ty<'tcx>,
68+
ty: Ty<'tcx>,
6869
kind: RetagKind,
6970
cx: &crate::MiriInterpCx<'_, 'tcx>,
7071
) -> Self {
@@ -864,7 +865,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
864865
RetagKind::FnEntry => unreachable!(),
865866
RetagKind::Raw | RetagKind::Default => RetagCause::Normal,
866867
};
867-
this.sb_retag_reference(&val, new_perm, retag_cause)
868+
this.sb_retag_reference(val, new_perm, retag_cause)
868869
}
869870

870871
fn sb_retag_place_contents(

0 commit comments

Comments
 (0)