Skip to content

Commit b258eb3

Browse files
committed
Auto merge of #1911 - RalfJung:rename-track-tag, r=RalfJung
rename track-raw-pointers flag to tag-raw-pointers The old flag name sounds too similar to `-Zmiri-track-pointer-tag`, which is a totally different kind of 'tracking'. This has lead to confusion in #1907.
2 parents e41c479 + d8bee92 commit b258eb3

File tree

17 files changed

+34
-29
lines changed

17 files changed

+34
-29
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,13 @@ environment variable:
276276
is popped from a borrow stack (which is where the tag becomes invalid and any
277277
future use of it will error). This helps you in finding out why UB is
278278
happening and where in your code would be a good place to look for it.
279-
* `-Zmiri-track-raw-pointers` makes Stacked Borrows track a pointer tag even for
280-
raw pointers. This can make valid code fail to pass the checks, but also can
281-
help identify latent aliasing issues in code that Miri accepts by default. You
282-
can recognize false positives by `<untagged>` occurring in the message -- this
283-
indicates a pointer that was cast from an integer, so Miri was unable to track
284-
this pointer. Note that it is not currently guaranteed that code that works
285-
with `-Zmiri-track-raw-pointers` also works without
286-
`-Zmiri-track-raw-pointers`, but for the vast majority of code, this will be the case.
279+
* `-Zmiri-tag-raw-pointers` makes Stacked Borrows assign proper tags even for raw pointers. This can
280+
make valid code using int-to-ptr casts fail to pass the checks, but also can help identify latent
281+
aliasing issues in code that Miri accepts by default. You can recognize false positives by
282+
`<untagged>` occurring in the message -- this indicates a pointer that was cast from an integer,
283+
so Miri was unable to track this pointer. Note that it is not currently guaranteed that code that
284+
works with `-Zmiri-tag-raw-pointers` also works without `-Zmiri-tag-raw-pointers`, but for the
285+
vast majority of code, this will be the case.
287286

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

src/bin/miri.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,14 @@ fn main() {
359359
"-Zmiri-panic-on-unsupported" => {
360360
miri_config.panic_on_unsupported = true;
361361
}
362+
"-Zmiri-tag-raw-pointers" => {
363+
miri_config.tag_raw = true;
364+
}
362365
"-Zmiri-track-raw-pointers" => {
363-
miri_config.track_raw = true;
366+
eprintln!(
367+
"WARNING: -Zmiri-track-raw-pointers has been renamed to -Zmiri-tag-raw-pointers, the old name is deprecated."
368+
);
369+
miri_config.tag_raw = true;
364370
}
365371
"--" => {
366372
after_dashdash = true;

src/eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct MiriConfig {
8787
/// The allocation id to report about.
8888
pub tracked_alloc_id: Option<AllocId>,
8989
/// Whether to track raw pointers in stacked borrows.
90-
pub track_raw: bool,
90+
pub tag_raw: bool,
9191
/// Determine if data race detection should be enabled
9292
pub data_race_detector: bool,
9393
/// Rate of spurious failures for compare_exchange_weak atomic operations,
@@ -116,7 +116,7 @@ impl Default for MiriConfig {
116116
tracked_pointer_tag: None,
117117
tracked_call_id: None,
118118
tracked_alloc_id: None,
119-
track_raw: false,
119+
tag_raw: false,
120120
data_race_detector: true,
121121
cmpxchg_weak_failure_rate: 0.8,
122122
measureme_out: None,

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl MemoryExtra {
194194
Some(RefCell::new(stacked_borrows::GlobalState::new(
195195
config.tracked_pointer_tag,
196196
config.tracked_call_id,
197-
config.track_raw,
197+
config.tag_raw,
198198
)))
199199
} else {
200200
None

src/stacked_borrows.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct GlobalState {
105105
/// The call id to trace
106106
tracked_call_id: Option<CallId>,
107107
/// Whether to track raw pointers.
108-
track_raw: bool,
108+
tag_raw: bool,
109109
}
110110
/// Memory extra state gives us interior mutable access to the global state.
111111
pub type MemoryExtra = RefCell<GlobalState>;
@@ -156,7 +156,7 @@ impl GlobalState {
156156
pub fn new(
157157
tracked_pointer_tag: Option<PtrId>,
158158
tracked_call_id: Option<CallId>,
159-
track_raw: bool,
159+
tag_raw: bool,
160160
) -> Self {
161161
GlobalState {
162162
next_ptr_id: NonZeroU64::new(1).unwrap(),
@@ -165,7 +165,7 @@ impl GlobalState {
165165
active_calls: FxHashSet::default(),
166166
tracked_pointer_tag,
167167
tracked_call_id,
168-
track_raw,
168+
tag_raw,
169169
}
170170
}
171171

@@ -532,7 +532,7 @@ impl Stacks {
532532
MiriMemoryKind::Rust | MiriMemoryKind::C | MiriMemoryKind::WinHeap,
533533
) => {
534534
let tag =
535-
if extra.track_raw { extra.base_tag(id) } else { extra.base_tag_untagged(id) };
535+
if extra.tag_raw { extra.base_tag(id) } else { extra.base_tag_untagged(id) };
536536
(tag, Permission::SharedReadWrite)
537537
}
538538
};
@@ -719,7 +719,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
719719
let mem_extra = this.memory.extra.stacked_borrows.as_mut().unwrap().get_mut();
720720
match kind {
721721
// Give up tracking for raw pointers.
722-
RefKind::Raw { .. } if !mem_extra.track_raw => SbTag::Untagged,
722+
RefKind::Raw { .. } if !mem_extra.tag_raw => SbTag::Untagged,
723723
// All other pointers are properly tracked.
724724
_ => SbTag::Tagged(mem_extra.new_ptr()),
725725
}

test-cargo-miri/run-test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_cargo_miri_test():
127127
test("`cargo miri test` (raw-ptr tracking)",
128128
cargo_miri("test"),
129129
default_ref, "test.stderr-empty.ref",
130-
env={'MIRIFLAGS': "-Zmiri-track-raw-pointers"},
130+
env={'MIRIFLAGS': "-Zmiri-tag-raw-pointers"},
131131
)
132132
test("`cargo miri test` (with filter)",
133133
cargo_miri("test") + ["--", "--format=pretty", "le1"],

tests/compile-fail/box-cell-alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
1+
// compile-flags: -Zmiri-tag-raw-pointers
22

33
// Taken from <https://github.com/rust-lang/unsafe-code-guidelines/issues/194#issuecomment-520934222>.
44

tests/compile-fail/stacked_borrows/raw_tracking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
1+
// compile-flags: -Zmiri-tag-raw-pointers
22
//! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.
33
44
fn main() {

tests/compile-fail/stacked_borrows/zst_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
1+
// compile-flags: -Zmiri-tag-raw-pointers
22
// error-pattern: does not have an appropriate item in the borrow stack
33

44
fn main() {

tests/run-pass/btreemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
1+
// compile-flags: -Zmiri-tag-raw-pointers
22
#![feature(btree_drain_filter)]
33
use std::collections::{BTreeMap, BTreeSet};
44
use std::mem;

0 commit comments

Comments
 (0)