Skip to content

Commit 5151b8c

Browse files
committed
Auto merge of #119039 - RalfJung:miri, r=RalfJung
Miri subtree update r? `@ghost`
2 parents 9f13b9d + 00a82a5 commit 5151b8c

25 files changed

+491
-354
lines changed

src/tools/miri/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ to run the other checks while ignoring the ui output, use `MIRI_SKIP_UI_CHECKS=1
109109

110110
For more info on how to configure ui tests see [the documentation on the ui test crate][ui_test]
111111

112-
[ui_test]: ui_test/README.md
112+
[ui_test]: https://github.com/oli-obk/ui_test/blob/main/README.md
113113

114114
### Testing `cargo miri`
115115

src/tools/miri/cargo-miri/src/util.rs

-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, text: &str) {
200200
// cargo invocation.
201201
fn cargo_extra_flags() -> Vec<String> {
202202
let mut flags = Vec::new();
203-
// `-Zunstable-options` is required by `--config`.
204-
flags.push("-Zunstable-options".to_string());
205-
206203
// Forward `--config` flags.
207204
let config_flag = "--config";
208205
for arg in get_arg_flag_values(config_flag) {

src/tools/miri/miri

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
set -e
33
# Instead of doing just `cargo run --manifest-path .. $@`, we invoke miri-script binary directly. Invoking `cargo run` goes through
44
# rustup (that sets it's own environmental variables), which is undesirable.
5-
cargo build $CARGO_EXTRA_FLAGS -q --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
6-
"$(dirname "$0")"/miri-script/target/debug/miri-script "$@"
5+
MIRI_SCRIPT_TARGET_DIR="$(dirname "$0")"/miri-script/target
6+
cargo build $CARGO_EXTRA_FLAGS -q --target-dir "$MIRI_SCRIPT_TARGET_DIR" --manifest-path "$(dirname "$0")"/miri-script/Cargo.toml
7+
"$MIRI_SCRIPT_TARGET_DIR"/debug/miri-script "$@"

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ impl MiriEnv {
7373
flags.push("-C link-args=-Wl,-rpath,");
7474
flags.push(libdir);
7575
// Enable rustc-specific lints (ignored without `-Zunstable-options`).
76-
flags.push(" -Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros");
76+
flags.push(
77+
" -Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes",
78+
);
7779
// Add user-defined flags.
7880
if let Some(value) = std::env::var_os("RUSTFLAGS") {
7981
flags.push(" ");

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
317d14a56cb8c748bf0e2f2afff89c2249ab4423
1+
604f185fae9a4b0edf7e28f616a0f53880f8f074

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub struct FrameState {
6565
/// incremental updates of the global list of protected tags stored in the
6666
/// `stacked_borrows::GlobalState` upon function return, and if we attempt to pop a protected
6767
/// tag, to identify which call is responsible for protecting the tag.
68-
/// See `Stack::item_popped` for more explanation.
68+
/// See `Stack::item_invalidated` for more explanation.
6969
/// Tree Borrows also needs to know which allocation these tags
7070
/// belong to so that it can perform a read through them immediately before
7171
/// the frame gets popped.
@@ -76,8 +76,10 @@ pub struct FrameState {
7676
}
7777

7878
impl VisitProvenance for FrameState {
79-
fn visit_provenance(&self, _visit: &mut VisitWith<'_>) {
80-
// `protected_tags` are already recorded by `GlobalStateInner`.
79+
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
80+
for (id, tag) in &self.protected_tags {
81+
visit(Some(*id), Some(*tag));
82+
}
8183
}
8284
}
8385

@@ -98,7 +100,7 @@ pub struct GlobalStateInner {
98100
/// An item is protected if its tag is in this set, *and* it has the "protected" bit set.
99101
/// We add tags to this when they are created with a protector in `reborrow`, and
100102
/// we remove tags from this when the call which is protecting them returns, in
101-
/// `GlobalStateInner::end_call`. See `Stack::item_popped` for more details.
103+
/// `GlobalStateInner::end_call`. See `Stack::item_invalidated` for more details.
102104
protected_tags: FxHashMap<BorTag, ProtectorKind>,
103105
/// The pointer ids to trace
104106
tracked_pointer_tags: FxHashSet<BorTag>,
@@ -111,10 +113,8 @@ pub struct GlobalStateInner {
111113
}
112114

113115
impl VisitProvenance for GlobalStateInner {
114-
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
115-
for &tag in self.protected_tags.keys() {
116-
visit(None, Some(tag));
117-
}
116+
fn visit_provenance(&self, _visit: &mut VisitWith<'_>) {
117+
// All the provenance in protected_tags is also stored in FrameState, and visited there.
118118
// The only other candidate is base_ptr_tags, and that does not need visiting since we don't ever
119119
// GC the bottommost/root tag.
120120
}

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ use rustc_data_structures::fx::FxHashSet;
55
use rustc_span::{Span, SpanData};
66
use rustc_target::abi::Size;
77

8-
use crate::borrow_tracker::{
9-
AccessKind, GlobalStateInner, ProtectorKind,
10-
};
8+
use crate::borrow_tracker::{AccessKind, GlobalStateInner, ProtectorKind};
119
use crate::*;
1210

1311
/// Error reporting

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ use rustc_target::abi::{Abi, Size};
1818

1919
use crate::borrow_tracker::{
2020
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
21-
AccessKind, GlobalStateInner, ProtectorKind,};
21+
AccessKind, GlobalStateInner, ProtectorKind,
22+
};
2223
use crate::*;
2324

2425
use diagnostics::{RetagCause, RetagInfo};

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use log::trace;
22

33
use rustc_target::abi::{Abi, Size};
44

5-
use crate::borrow_tracker::{
6-
AccessKind, GlobalState, GlobalStateInner, ProtectorKind,
7-
};
5+
use crate::borrow_tracker::{AccessKind, GlobalState, GlobalStateInner, ProtectorKind};
86
use rustc_middle::{
97
mir::{Mutability, RetagKind},
108
ty::{

src/tools/miri/src/shims/unix/linux/mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
3838
if flags & this.eval_libc_i32("MREMAP_MAYMOVE") == 0 {
3939
// We only support MREMAP_MAYMOVE, so not passing the flag is just a failure
4040
this.set_last_error(Scalar::from_i32(this.eval_libc_i32("EINVAL")))?;
41-
return Ok(Scalar::from_maybe_pointer(Pointer::null(), this));
41+
return Ok(this.eval_libc("MAP_FAILED"));
4242
}
4343

4444
let old_address = Machine::ptr_from_addr_cast(this, old_address)?;

src/tools/miri/src/shims/unix/mem.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
4848
// First, we do some basic argument validation as required by mmap
4949
if (flags & (map_private | map_shared)).count_ones() != 1 {
5050
this.set_last_error(Scalar::from_i32(this.eval_libc_i32("EINVAL")))?;
51-
return Ok(Scalar::from_maybe_pointer(Pointer::null(), this));
51+
return Ok(this.eval_libc("MAP_FAILED"));
5252
}
5353
if length == 0 {
5454
this.set_last_error(Scalar::from_i32(this.eval_libc_i32("EINVAL")))?;
55-
return Ok(Scalar::from_maybe_pointer(Pointer::null(), this));
55+
return Ok(this.eval_libc("MAP_FAILED"));
5656
}
5757

5858
// If a user tries to map a file, we want to loudly inform them that this is not going
@@ -72,7 +72,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7272
// Miri doesn't support MAP_FIXED or any any protections other than PROT_READ|PROT_WRITE.
7373
if flags & map_fixed != 0 || prot != prot_read | prot_write {
7474
this.set_last_error(Scalar::from_i32(this.eval_libc_i32("ENOTSUP")))?;
75-
return Ok(Scalar::from_maybe_pointer(Pointer::null(), this));
75+
return Ok(this.eval_libc("MAP_FAILED"));
7676
}
7777

7878
// Miri does not support shared mappings, or any of the other extensions that for example

0 commit comments

Comments
 (0)