Skip to content

Commit 386d4b1

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref '460259d14de0' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 460259d14de0274b97b8801e08cb2fe5f16fdac5 Filtered ref: 599ee17eb87c83f97eb37fd9fe264da65d4c9461 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents c909d74 + c7bff23 commit 386d4b1

Some content is hidden

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

43 files changed

+241
-65
lines changed

src/alloc_addresses/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
157157
this.get_alloc_bytes_unchecked_raw(alloc_id)?
158158
}
159159
}
160-
AllocKind::Function | AllocKind::VTable => {
160+
AllocKind::Function | AllocKind::Virtual => {
161161
// Allocate some dummy memory to get a unique address for this function/vtable.
162162
let alloc_bytes = MiriAllocBytes::from_bytes(
163163
&[0u8; 1],

src/bin/log/tracing_chrome.rs

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
// SPDX-License-Identifier: MIT
22
// SPDX-FileCopyrightText: Copyright (c) 2020 Thoren Paulson
3-
//! This file is taken unmodified from the following link, except for file attributes and
4-
//! `extern crate` at the top.
5-
//! https://github.com/thoren-d/tracing-chrome/blob/7e2625ab4aeeef2f0ef9bde9d6258dd181c04472/src/lib.rs
3+
//! This file was initially taken from the following link:
4+
//! <https://github.com/thoren-d/tracing-chrome/blob/7e2625ab4aeeef2f0ef9bde9d6258dd181c04472/src/lib.rs>
5+
//!
6+
//! The precise changes that were made to the original file can be found in git history
7+
//! (`git log -- path/to/tracing_chrome.rs`), but in summary:
8+
//! - the file attributes were changed and `extern crate` was added at the top
9+
//! - if a tracing span has a field called "tracing_separate_thread", it will be given a separate
10+
//! span ID even in [TraceStyle::Threaded] mode, to make it appear on a separate line when viewing
11+
//! the trace in <https://ui.perfetto.dev>. This is the syntax to trigger this behavior:
12+
//! ```rust
13+
//! tracing::info_span!("my_span", tracing_separate_thread = tracing::field::Empty, /* ... */)
14+
//! ```
15+
//!
616
//! Depending on the tracing-chrome crate from crates.io is unfortunately not possible, since it
717
//! depends on `tracing_core` which conflicts with rustc_private's `tracing_core` (meaning it would
818
//! not be possible to use the [ChromeLayer] in a context that expects a [Layer] from
@@ -79,14 +89,26 @@ where
7989
}
8090

8191
/// Decides how traces will be recorded.
92+
/// Also see <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1>
8293
#[derive(Default)]
8394
pub enum TraceStyle {
84-
/// Traces will be recorded as a group of threads.
95+
/// Traces will be recorded as a group of threads, and all spans on the same thread will appear
96+
/// on a single trace line in <https://ui.perfetto.dev>.
8597
/// In this style, spans should be entered and exited on the same thread.
98+
///
99+
/// If a tracing span has a field called "tracing_separate_thread", it will be given a separate
100+
/// span ID even in this mode, to make it appear on a separate line when viewing the trace in
101+
/// <https://ui.perfetto.dev>. This is the syntax to trigger this behavior:
102+
/// ```rust
103+
/// tracing::info_span!("my_span", tracing_separate_thread = tracing::field::Empty, /* ... */)
104+
/// ```
105+
/// [tracing::field::Empty] is used so that other tracing layers (e.g. the logger) will ignore
106+
/// the "tracing_separate_thread" argument and not print out anything for it.
86107
#[default]
87108
Threaded,
88109

89-
/// Traces will recorded as a group of asynchronous operations.
110+
/// Traces will recorded as a group of asynchronous operations. All spans will be given separate
111+
/// span IDs and will appear on separate trace lines in <https://ui.perfetto.dev>.
90112
Async,
91113
}
92114

@@ -497,31 +519,39 @@ where
497519
}
498520
}
499521

500-
fn get_root_id(span: SpanRef<S>) -> u64 {
501-
span.scope()
502-
.from_root()
503-
.take(1)
504-
.next()
505-
.unwrap_or(span)
506-
.id()
507-
.into_u64()
522+
fn get_root_id(&self, span: SpanRef<S>) -> Option<u64> {
523+
match self.trace_style {
524+
TraceStyle::Threaded => {
525+
if span.fields().field("tracing_separate_thread").is_some() {
526+
// assign an independent "id" to spans with argument "tracing_separate_thread",
527+
// so they appear a separate trace line in trace visualization tools, see
528+
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1
529+
Some(span.id().into_u64())
530+
} else {
531+
None
532+
}
533+
},
534+
TraceStyle::Async => Some(
535+
span.scope()
536+
.from_root()
537+
.take(1)
538+
.next()
539+
.unwrap_or(span)
540+
.id()
541+
.into_u64()
542+
),
543+
}
508544
}
509545

510546
fn enter_span(&self, span: SpanRef<S>, ts: f64) {
511547
let callsite = self.get_callsite(EventOrSpan::Span(&span));
512-
let root_id = match self.trace_style {
513-
TraceStyle::Async => Some(ChromeLayer::get_root_id(span)),
514-
_ => None,
515-
};
548+
let root_id = self.get_root_id(span);
516549
self.send_message(Message::Enter(ts, callsite, root_id));
517550
}
518551

519552
fn exit_span(&self, span: SpanRef<S>, ts: f64) {
520553
let callsite = self.get_callsite(EventOrSpan::Span(&span));
521-
let root_id = match self.trace_style {
522-
TraceStyle::Async => Some(ChromeLayer::get_root_id(span)),
523-
_ => None,
524-
};
554+
let root_id = self.get_root_id(span);
525555
self.send_message(Message::Exit(ts, callsite, root_id));
526556
}
527557

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
650650
dcx.log_protector();
651651
}
652652
},
653-
AllocKind::Function | AllocKind::VTable | AllocKind::Dead => {
653+
AllocKind::Function | AllocKind::Virtual | AllocKind::Dead => {
654654
// No stacked borrows on these allocations.
655655
}
656656
}
@@ -1021,7 +1021,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
10211021
trace!("Stacked Borrows tag {tag:?} exposed in {alloc_id:?}");
10221022
alloc_extra.borrow_tracker_sb().borrow_mut().exposed_tags.insert(tag);
10231023
}
1024-
AllocKind::Function | AllocKind::VTable | AllocKind::Dead => {
1024+
AllocKind::Function | AllocKind::Virtual | AllocKind::Dead => {
10251025
// No stacked borrows on these allocations.
10261026
}
10271027
}

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
673673
trace!("Tree Borrows tag {tag:?} exposed in {alloc_id:?}");
674674
alloc_extra.borrow_tracker_tb().borrow_mut().expose_tag(tag);
675675
}
676-
AllocKind::Function | AllocKind::VTable | AllocKind::Dead => {
676+
AllocKind::Function | AllocKind::Virtual | AllocKind::Dead => {
677677
// No tree borrows on these allocations.
678678
}
679679
}

src/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
10861086
ecx: &MiriInterpCx<'tcx>,
10871087
instance: ty::Instance<'tcx>,
10881088
) -> InterpResult<'tcx> {
1089-
let attrs = ecx.tcx.codegen_fn_attrs(instance.def_id());
1089+
let attrs = ecx.tcx.codegen_instance_attrs(instance.def);
10901090
if attrs
10911091
.target_features
10921092
.iter()
@@ -1790,7 +1790,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
17901790
ecx.tcx.sess.opts.unstable_opts.cross_crate_inline_threshold,
17911791
InliningThreshold::Always
17921792
) || !matches!(
1793-
ecx.tcx.codegen_fn_attrs(instance.def_id()).inline,
1793+
ecx.tcx.codegen_instance_attrs(instance.def).inline,
17941794
InlineAttr::Never
17951795
);
17961796
!is_generic && !can_be_inlined

tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
3+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
24

35
/// Test that destroying a pthread_cond twice fails, even without a check for number validity
46
@@ -15,6 +17,6 @@ fn main() {
1517
libc::pthread_cond_destroy(cond.as_mut_ptr());
1618

1719
libc::pthread_cond_destroy(cond.as_mut_ptr());
18-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
20+
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
1921
}
2022
}

tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
@@ -9,6 +9,9 @@ LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC DUMP
14+
1215
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1316

1417
error: aborting due to 1 previous error

tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ignore-target: windows # No pthreads on Windows
22
//@ignore-target: apple # Our macOS condattr don't have any fields so we do not notice this.
3+
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
4+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
35

46
/// Test that destroying a pthread_condattr twice fails, even without a check for number validity
57
@@ -13,6 +15,6 @@ fn main() {
1315
libc::pthread_condattr_destroy(attr.as_mut_ptr());
1416

1517
libc::pthread_condattr_destroy(attr.as_mut_ptr());
16-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
18+
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
1719
}
1820
}

tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
1+
error: Undefined Behavior: reading memory at ALLOC[0xX..0xY], but memory is uninitialized at [0xX..0xY], and this operation requires initialized memory
22
--> tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
@@ -9,6 +9,9 @@ LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
99
= note: BACKTRACE:
1010
= note: inside `main` at tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
1111

12+
Uninitialized memory occurred at ALLOC[0xX..0xY], in this allocation:
13+
ALLOC DUMP
14+
1215
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1316

1417
error: aborting due to 1 previous error

tests/fail-dep/concurrency/libc_pthread_mutex_double_destroy.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ignore-target: windows # No pthreads on Windows
2+
//@ normalize-stderr-test: "(\n)ALLOC \(.*\) \{\n(.*\n)*\}(\n)" -> "${1}ALLOC DUMP${3}"
3+
//@ normalize-stderr-test: "\[0x[0-9a-z]..0x[0-9a-z]\]" -> "[0xX..0xY]"
24

35
/// Test that destroying a pthread_mutex twice fails, even without a check for number validity
46
@@ -16,6 +18,6 @@ fn main() {
1618
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
1719

1820
libc::pthread_mutex_destroy(mutex.as_mut_ptr());
19-
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
21+
//~^ ERROR: /Undefined Behavior: reading memory .*, but memory is uninitialized/
2022
}
2123
}

0 commit comments

Comments
 (0)