Skip to content

Commit 19e41ba

Browse files
committed
Auto merge of #113151 - RalfJung:miri, r=RalfJung,oli-obk
update Miri r? `@ghost`
2 parents 94a94a9 + 6e3da5f commit 19e41ba

File tree

205 files changed

+3204
-464
lines changed

Some content is hidden

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

205 files changed

+3204
-464
lines changed

.github/workflows/ci.yml

+25-1
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ jobs:
156156
- name: mark the job as a failure
157157
run: exit 1
158158

159-
# Send a Zulip notification when a cron job fails
160159
cron-fail-notify:
161160
name: cronjob failure notification
162161
runs-on: ubuntu-latest
163162
needs: [build, style]
164163
if: github.event_name == 'schedule' && (failure() || cancelled())
165164
steps:
165+
# Send a Zulip notification
166166
- name: Install zulip-send
167167
run: pip3 install zulip
168168
- name: Send Zulip notification
@@ -185,3 +185,27 @@ jobs:
185185
Sincerely,
186186
The Miri Cronjobs Bot' \
187187
--user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com
188+
# Attempt to auto-sync with rustc
189+
- name: install josh-proxy
190+
run: cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r22.12.06
191+
- name: start josh-proxy
192+
run: josh-proxy --local=$HOME/.cache/josh --remote=https://github.com --no-background &
193+
- name: setup bot git name and email
194+
run: |
195+
git config --global user.name 'The Miri Conjob Bot'
196+
git config --global user.email '[email protected]'
197+
- name: get changes from rustc
198+
run: ./miri rustc-pull
199+
- name: format changes (if any)
200+
run: |
201+
./miri toolchain
202+
./miri fmt --check || (./miri fmt && git commit -am "fmt")
203+
- name: Push changes to a branch
204+
run: |
205+
git switch -c "rustup$(date -u +%Y-%m)"
206+
git push
207+
- name: Create Pull Request
208+
run: gh pr create -B master --title 'Automatic sync from rustc' --body ''
209+
env:
210+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211+

Cargo.lock

+2-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ log = "0.4"
2424
rand = "0.8"
2525
smallvec = "1.7"
2626

27-
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
28-
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
29-
# for more information.
30-
rustc-workspace-hack = "1.0.0"
3127
measureme = "10.0.0"
3228
ctrlc = "3.2.5"
3329

@@ -40,7 +36,7 @@ libloading = "0.7"
4036

4137
[dev-dependencies]
4238
colored = "2"
43-
ui_test = "0.10"
39+
ui_test = "0.11.6"
4440
rustc_version = "0.4"
4541
# Features chosen to match those required by env_logger, to avoid rebuilds
4642
regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] }

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ to Miri failing to detect cases of undefined behavior in a program.
435435
so with this flag.
436436
* `-Zmiri-force-page-size=<num>` overrides the default page size for an architecture, in multiples of 1k.
437437
`4` is default for most targets. This value should always be a power of 2 and nonzero.
438+
* `-Zmiri-unique-is-unique` performs additional aliasing checks for `core::ptr::Unique` to ensure
439+
that it could theoretically be considered `noalias`. This flag is experimental and has
440+
an effect only when used with `-Zmiri-tree-borrows`.
438441

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

@@ -575,6 +578,7 @@ Definite bugs found:
575578
* [`crossbeam-epoch` calling `assume_init` on a partly-initialized `MaybeUninit`](https://github.com/crossbeam-rs/crossbeam/pull/779)
576579
* [`integer-encoding` dereferencing a misaligned pointer](https://github.com/dermesser/integer-encoding-rs/pull/23)
577580
* [`rkyv` constructing a `Box<[u8]>` from an overaligned allocation](https://github.com/rkyv/rkyv/commit/a9417193a34757e12e24263178be8b2eebb72456)
581+
* [Data race in `arc-swap`](https://github.com/vorner/arc-swap/issues/76)
578582
* [Data race in `thread::scope`](https://github.com/rust-lang/rust/issues/98498)
579583
* [`regex` incorrectly handling unaligned `Vec<u8>` buffers](https://www.reddit.com/r/rust/comments/vq3mmu/comment/ienc7t0?context=3)
580584
* [Incorrect use of `compare_exchange_weak` in `once_cell`](https://github.com/matklad/once_cell/issues/186)

cargo-miri/Cargo.lock

-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cargo-miri/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ serde_json = "1.0.40"
2020
cargo_metadata = "0.15.0"
2121
rustc-build-sysroot = "0.4.1"
2222

23-
# A noop dependency that changes in the Rust repository, it's a bit of a hack.
24-
# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust`
25-
# for more information.
26-
rustc-workspace-hack = "1.0.0"
27-
2823
# Enable some feature flags that dev-dependencies need but dependencies
2924
# do not. This makes `./miri install` after `./miri build` faster.
3025
serde = { version = "*", features = ["derive"] }

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
33c3d101280c8eb3cd8af421bfb56a8afcc3881d
1+
75726cae37317c7262b69d3e9fd11a3496a88d04

src/bin/miri.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ use rustc_middle::{
3131
query::{ExternProviders, LocalCrate},
3232
ty::TyCtxt,
3333
};
34-
use rustc_session::{EarlyErrorHandler, CtfeBacktrace};
35-
use rustc_session::config::{OptLevel, CrateType, ErrorOutputType};
34+
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
3635
use rustc_session::search_paths::PathKind;
36+
use rustc_session::{CtfeBacktrace, EarlyErrorHandler};
3737

3838
use miri::{BacktraceStyle, BorrowTrackerMethod, ProvenanceMode, RetagFields};
3939

@@ -343,6 +343,8 @@ fn main() {
343343
miri_config.borrow_tracker = None;
344344
} else if arg == "-Zmiri-tree-borrows" {
345345
miri_config.borrow_tracker = Some(BorrowTrackerMethod::TreeBorrows);
346+
} else if arg == "-Zmiri-unique-is-unique" {
347+
miri_config.unique_is_unique = true;
346348
} else if arg == "-Zmiri-disable-data-race-detector" {
347349
miri_config.data_race_detector = false;
348350
miri_config.weak_memory_emulation = false;
@@ -560,6 +562,14 @@ fn main() {
560562
rustc_args.push(arg);
561563
}
562564
}
565+
// `-Zmiri-unique-is-unique` should only be used with `-Zmiri-tree-borrows`
566+
if miri_config.unique_is_unique
567+
&& !matches!(miri_config.borrow_tracker, Some(BorrowTrackerMethod::TreeBorrows))
568+
{
569+
show_error!(
570+
"-Zmiri-unique-is-unique only has an effect when -Zmiri-tree-borrows is also used"
571+
);
572+
}
563573

564574
debug!("rustc arguments: {:?}", rustc_args);
565575
debug!("crate arguments: {:?}", miri_config.args);

src/borrow_tracker/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ pub struct GlobalStateInner {
103103
pub tracked_call_ids: FxHashSet<CallId>,
104104
/// Whether to recurse into datatypes when searching for pointers to retag.
105105
pub retag_fields: RetagFields,
106+
/// Whether `core::ptr::Unique` gets special (`Box`-like) handling.
107+
pub unique_is_unique: bool,
106108
}
107109

108110
impl VisitTags for GlobalStateInner {
@@ -170,6 +172,7 @@ impl GlobalStateInner {
170172
tracked_pointer_tags: FxHashSet<BorTag>,
171173
tracked_call_ids: FxHashSet<CallId>,
172174
retag_fields: RetagFields,
175+
unique_is_unique: bool,
173176
) -> Self {
174177
GlobalStateInner {
175178
borrow_tracker_method,
@@ -180,6 +183,7 @@ impl GlobalStateInner {
180183
tracked_pointer_tags,
181184
tracked_call_ids,
182185
retag_fields,
186+
unique_is_unique,
183187
}
184188
}
185189

@@ -244,6 +248,7 @@ impl BorrowTrackerMethod {
244248
config.tracked_pointer_tags.clone(),
245249
config.tracked_call_ids.clone(),
246250
config.retag_fields,
251+
config.unique_is_unique,
247252
))
248253
}
249254
}

src/borrow_tracker/tree_borrows/diagnostics.rs

+50-19
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,46 @@ use crate::borrow_tracker::tree_borrows::{
1212
use crate::borrow_tracker::{AccessKind, ProtectorKind};
1313
use crate::*;
1414

15+
/// Cause of an access: either a real access or one
16+
/// inserted by Tree Borrows due to a reborrow or a deallocation.
17+
#[derive(Clone, Copy, Debug)]
18+
pub enum AccessCause {
19+
Explicit(AccessKind),
20+
Reborrow,
21+
Dealloc,
22+
}
23+
24+
impl fmt::Display for AccessCause {
25+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26+
match self {
27+
Self::Explicit(kind) => write!(f, "{kind}"),
28+
Self::Reborrow => write!(f, "reborrow"),
29+
Self::Dealloc => write!(f, "deallocation"),
30+
}
31+
}
32+
}
33+
34+
impl AccessCause {
35+
fn print_as_access(self, is_foreign: bool) -> String {
36+
let rel = if is_foreign { "foreign" } else { "child" };
37+
match self {
38+
Self::Explicit(kind) => format!("{rel} {kind}"),
39+
Self::Reborrow => format!("reborrow (acting as a {rel} read access)"),
40+
Self::Dealloc => format!("deallocation (acting as a {rel} write access)"),
41+
}
42+
}
43+
}
44+
1545
/// Complete data for an event:
1646
#[derive(Clone, Debug)]
1747
pub struct Event {
18-
/// Transformation of permissions that occured because of this event
48+
/// Transformation of permissions that occured because of this event.
1949
pub transition: PermTransition,
20-
/// Kind of the access that triggered this event
21-
pub access_kind: AccessKind,
22-
/// Relative position of the tag to the one used for the access
50+
/// Kind of the access that triggered this event.
51+
pub access_cause: AccessCause,
52+
/// Relative position of the tag to the one used for the access.
2353
pub is_foreign: bool,
24-
/// User-visible range of the access
54+
/// User-visible range of the access.
2555
pub access_range: AllocRange,
2656
/// The transition recorded by this event only occured on a subrange of
2757
/// `access_range`: a single access on `access_range` triggers several events,
@@ -36,7 +66,7 @@ pub struct Event {
3666
/// the `TbError`, which should satisfy
3767
/// `event.transition_range.contains(error.error_offset)`.
3868
pub transition_range: Range<u64>,
39-
/// Line of code that triggered this event
69+
/// Line of code that triggered this event.
4070
pub span: Span,
4171
}
4272

@@ -83,17 +113,19 @@ impl HistoryData {
83113
self.events.push((Some(created.0.data()), msg_creation));
84114
for &Event {
85115
transition,
86-
access_kind,
87116
is_foreign,
117+
access_cause,
88118
access_range,
89119
span,
90120
transition_range: _,
91121
} in &events
92122
{
93123
// NOTE: `transition_range` is explicitly absent from the error message, it has no significance
94124
// to the user. The meaningful one is `access_range`.
95-
self.events.push((Some(span.data()), format!("{this} later transitioned to {endpoint} due to a {rel} {access_kind} at offsets {access_range:?}", endpoint = transition.endpoint(), rel = if is_foreign { "foreign" } else { "child" })));
96-
self.events.push((None, format!("this corresponds to {}", transition.summary())));
125+
let access = access_cause.print_as_access(is_foreign);
126+
self.events.push((Some(span.data()), format!("{this} later transitioned to {endpoint} due to a {access} at offsets {access_range:?}", endpoint = transition.endpoint())));
127+
self.events
128+
.push((None, format!("this transition corresponds to {}", transition.summary())));
97129
}
98130
}
99131
}
@@ -238,9 +270,8 @@ pub(super) struct TbError<'node> {
238270
/// On accesses rejected due to insufficient permissions, this is the
239271
/// tag that lacked those permissions.
240272
pub conflicting_info: &'node NodeDebugInfo,
241-
/// Whether this was a Read or Write access. This field is ignored
242-
/// when the error was triggered by a deallocation.
243-
pub access_kind: AccessKind,
273+
// What kind of access caused this error (read, write, reborrow, deallocation)
274+
pub access_cause: AccessCause,
244275
/// Which tag the access that caused this error was made through, i.e.
245276
/// which tag was used to read/write/deallocate.
246277
pub accessed_info: &'node NodeDebugInfo,
@@ -250,46 +281,46 @@ impl TbError<'_> {
250281
/// Produce a UB error.
251282
pub fn build<'tcx>(self) -> InterpError<'tcx> {
252283
use TransitionError::*;
253-
let kind = self.access_kind;
284+
let cause = self.access_cause;
254285
let accessed = self.accessed_info;
255286
let conflicting = self.conflicting_info;
256287
let accessed_is_conflicting = accessed.tag == conflicting.tag;
288+
let title = format!("{cause} through {accessed} is forbidden");
257289
let (title, details, conflicting_tag_name) = match self.error_kind {
258290
ChildAccessForbidden(perm) => {
259291
let conflicting_tag_name =
260292
if accessed_is_conflicting { "accessed" } else { "conflicting" };
261-
let title = format!("{kind} through {accessed} is forbidden");
262293
let mut details = Vec::new();
263294
if !accessed_is_conflicting {
264295
details.push(format!(
265296
"the accessed tag {accessed} is a child of the conflicting tag {conflicting}"
266297
));
267298
}
299+
let access = cause.print_as_access(/* is_foreign */ false);
268300
details.push(format!(
269-
"the {conflicting_tag_name} tag {conflicting} has state {perm} which forbids child {kind}es"
301+
"the {conflicting_tag_name} tag {conflicting} has state {perm} which forbids this {access}"
270302
));
271303
(title, details, conflicting_tag_name)
272304
}
273305
ProtectedTransition(transition) => {
274306
let conflicting_tag_name = "protected";
275-
let title = format!("{kind} through {accessed} is forbidden");
307+
let access = cause.print_as_access(/* is_foreign */ true);
276308
let details = vec![
277309
format!(
278310
"the accessed tag {accessed} is foreign to the {conflicting_tag_name} tag {conflicting} (i.e., it is not a child)"
279311
),
280312
format!(
281-
"the access would cause the {conflicting_tag_name} tag {conflicting} to transition {transition}"
313+
"this {access} would cause the {conflicting_tag_name} tag {conflicting} to transition {transition}"
282314
),
283315
format!(
284-
"this is {loss}, which is not allowed for protected tags",
316+
"this transition would be {loss}, which is not allowed for protected tags",
285317
loss = transition.summary(),
286318
),
287319
];
288320
(title, details, conflicting_tag_name)
289321
}
290322
ProtectedDealloc => {
291323
let conflicting_tag_name = "strongly protected";
292-
let title = format!("deallocation through {accessed} is forbidden");
293324
let details = vec![
294325
format!(
295326
"the allocation of the accessed tag {accessed} also contains the {conflicting_tag_name} tag {conflicting}"

0 commit comments

Comments
 (0)