Skip to content

Commit af37aca

Browse files
committed
print thread name in miri error backtraces
1 parent f79ea81 commit af37aca

File tree

117 files changed

+219
-170
lines changed

Some content is hidden

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

117 files changed

+219
-170
lines changed

src/concurrency/data_race.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,8 +1673,8 @@ impl GlobalState {
16731673
vector: VectorIdx,
16741674
) -> String {
16751675
let thread = self.vector_info.borrow()[vector];
1676-
let thread_name = thread_mgr.get_thread_name(thread);
1677-
format!("thread `{}`", String::from_utf8_lossy(thread_name))
1676+
let thread_name = thread_mgr.get_thread_display_name(thread);
1677+
format!("thread `{thread_name}`")
16781678
}
16791679

16801680
/// Acquire a lock, express that the previous call of

src/concurrency/thread.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,18 @@ pub type StackEmptyCallback<'mir, 'tcx> =
160160
Box<dyn FnMut(&mut MiriInterpCx<'mir, 'tcx>) -> InterpResult<'tcx, Poll<()>>>;
161161

162162
impl<'mir, 'tcx> Thread<'mir, 'tcx> {
163-
/// Get the name of the current thread, or `<unnamed>` if it was not set.
164-
fn thread_name(&self) -> &[u8] {
165-
if let Some(ref thread_name) = self.thread_name { thread_name } else { b"<unnamed>" }
163+
/// Get the name of the current thread if it was set.
164+
fn thread_name(&self) -> Option<&[u8]> {
165+
self.thread_name.as_deref()
166+
}
167+
168+
/// Get the name of the current thread for display purposes; will include thread ID if not set.
169+
fn thread_display_name(&self, id: ThreadId) -> String {
170+
if let Some(ref thread_name) = self.thread_name {
171+
String::from_utf8_lossy(thread_name).into_owned()
172+
} else {
173+
format!("unnamed-{}", id.index())
174+
}
166175
}
167176

168177
/// Return the top user-relevant frame, if there is one.
@@ -205,7 +214,7 @@ impl<'mir, 'tcx> std::fmt::Debug for Thread<'mir, 'tcx> {
205214
write!(
206215
f,
207216
"{}({:?}, {:?})",
208-
String::from_utf8_lossy(self.thread_name()),
217+
String::from_utf8_lossy(self.thread_name().unwrap_or(b"<unnamed>")),
209218
self.state,
210219
self.join_status
211220
)
@@ -572,10 +581,14 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
572581
}
573582

574583
/// Get the name of the given thread.
575-
pub fn get_thread_name(&self, thread: ThreadId) -> &[u8] {
584+
pub fn get_thread_name(&self, thread: ThreadId) -> Option<&[u8]> {
576585
self.threads[thread].thread_name()
577586
}
578587

588+
pub fn get_thread_display_name(&self, thread: ThreadId) -> String {
589+
self.threads[thread].thread_display_name(thread)
590+
}
591+
579592
/// Put the thread into the blocked state.
580593
fn block_thread(&mut self, thread: ThreadId) {
581594
let state = &mut self.threads[thread].state;
@@ -980,7 +993,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
980993
}
981994

982995
#[inline]
983-
fn get_thread_name<'c>(&'c self, thread: ThreadId) -> &'c [u8]
996+
fn get_thread_name<'c>(&'c self, thread: ThreadId) -> Option<&[u8]>
984997
where
985998
'mir: 'c,
986999
{

src/diagnostics.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ pub fn report_msg<'tcx>(
477477

478478
// Show note and help messages.
479479
let mut extra_span = false;
480-
let notes_len = notes.len();
481480
for (span_data, note) in notes {
482481
if let Some(span_data) = span_data {
483482
err.span_note(span_data.span(), note);
@@ -486,7 +485,6 @@ pub fn report_msg<'tcx>(
486485
err.note(note);
487486
}
488487
}
489-
let helps_len = helps.len();
490488
for (span_data, help) in helps {
491489
if let Some(span_data) = span_data {
492490
err.span_help(span_data.span(), help);
@@ -495,12 +493,20 @@ pub fn report_msg<'tcx>(
495493
err.help(help);
496494
}
497495
}
498-
if notes_len + helps_len > 0 {
499-
// Add visual separator before backtrace.
500-
err.note(if extra_span { "BACKTRACE (of the first span):" } else { "BACKTRACE:" });
501-
}
502496

503497
// Add backtrace
498+
let mut backtrace_title = String::from("BACKTRACE");
499+
if extra_span {
500+
write!(backtrace_title, " (of the first span)").unwrap();
501+
}
502+
let thread_name =
503+
machine.threads.get_thread_display_name(machine.threads.get_active_thread_id());
504+
if thread_name != "main" {
505+
// Only print thread name if it is not `main`.
506+
write!(backtrace_title, " on thread `{thread_name}`").unwrap();
507+
};
508+
write!(backtrace_title, ":").unwrap();
509+
err.note(backtrace_title);
504510
for (idx, frame_info) in stacktrace.iter().enumerate() {
505511
let is_local = machine.is_local(frame_info);
506512
// No span for non-local frames and the first frame (which is the error site).

src/shims/unix/thread.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
104104
let name_out = name_out.to_pointer(this)?;
105105
let len = len.to_target_usize(this)?;
106106

107-
let name = this.get_thread_name(thread).to_owned();
107+
// FIXME: we should use the program name if the thread name is not set
108+
let name = this.get_thread_name(thread).unwrap_or(b"<unnamed>").to_owned();
108109
let (success, _written) = this.write_c_str(&name, name_out, len)?;
109110

110111
Ok(if success { Scalar::from_u32(0) } else { this.eval_libc("ERANGE") })

tests/compiletest.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ regexes! {
172172
r"\.rs:[0-9]+:[0-9]+(: [0-9]+:[0-9]+)?" => ".rs:LL:CC",
173173
// erase alloc ids
174174
"alloc[0-9]+" => "ALLOC",
175+
// erase thread ids
176+
r"unnamed-[0-9]+" => "unnamed-ID",
175177
// erase borrow tags
176178
"<[0-9]+>" => "<TAG>",
177179
"<[0-9]+=" => "<TAG=",

tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | panic!()
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC
1111
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
1212

tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | panic!()
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside `thread_start` at RUSTLIB/core/src/panic.rs:LL:CC
1111
= note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
1212

tests/fail-dep/concurrency/libc_pthread_join_main.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0);
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_join_main.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/concurrency/libc_pthread_join_multiple.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | ... assert_eq!(libc::pthread_join(native_copy, ptr::null_mut()), 0);
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_join_multiple.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/concurrency/libc_pthread_join_self.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_join_self.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/concurrency/unwind_top_of_stack.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | | }
1414
|
1515
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1616
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
17-
= note: BACKTRACE:
17+
= note: BACKTRACE on thread `unnamed-ID`:
1818
= note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC
1919

2020
error: aborting due to 1 previous error

tests/fail-dep/shims/env-set_var-data-race.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `main` and (2) non-atomic read on thread `<unnamed>` at ALLOC. (2) just happened here
1+
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `main` and (2) non-atomic read on thread `unnamed-ID` at ALLOC. (2) just happened here
22
--> $DIR/env-set_var-data-race.rs:LL:CC
33
|
44
LL | libc::getenv(b"TZ/0".as_ptr().cast());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) non-atomic write on thread `main` and (2) non-atomic read on thread `<unnamed>` at ALLOC. (2) just happened here
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) non-atomic write on thread `main` and (2) non-atomic read on thread `unnamed-ID` at ALLOC. (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> $DIR/env-set_var-data-race.rs:LL:CC
@@ -11,7 +11,7 @@ LL | env::set_var("MY_RUST_VAR", "Ferris");
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1313
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14-
= note: BACKTRACE (of the first span):
14+
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
1515
= note: inside closure at $DIR/env-set_var-data-race.rs:LL:CC
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_mutex_deadlock.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | assert_eq!(libc::pthread_mutex_lock(lock_copy.0.get() as *mut _), 0);
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE on thread `unnamed-ID`:
78
= note: inside closure at $DIR/libc_pthread_mutex_deadlock.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_mutex_normal_deadlock.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | libc::pthread_mutex_lock(&mut mutex as *mut _);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE:
78
= note: inside `main` at $DIR/libc_pthread_mutex_normal_deadlock.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_mutex_wrong_owner.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | ...t_eq!(libc::pthread_mutex_unlock(lock_copy.0.get() as *mut _), 0);
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_mutex_wrong_owner.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_read_write_deadlock_single_thread.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | libc::pthread_rwlock_wrlock(rw.get());
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE:
78
= note: inside `main` at $DIR/libc_pthread_rwlock_read_write_deadlock_single_thread.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_read_wrong_owner.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _),
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_rwlock_read_wrong_owner.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0);
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE on thread `unnamed-ID`:
78
= note: inside closure at $DIR/libc_pthread_rwlock_write_read_deadlock.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_write_read_deadlock_single_thread.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | libc::pthread_rwlock_rdlock(rw.get());
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE:
78
= note: inside `main` at $DIR/libc_pthread_rwlock_write_read_deadlock_single_thread.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | assert_eq!(libc::pthread_rwlock_wrlock(lock_copy.0.get() as *mut _), 0);
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE on thread `unnamed-ID`:
78
= note: inside closure at $DIR/libc_pthread_rwlock_write_write_deadlock.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_write_write_deadlock_single_thread.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: deadlock: the evaluated program deadlocked
44
LL | libc::pthread_rwlock_wrlock(rw.get());
55
| ^ the evaluated program deadlocked
66
|
7+
= note: BACKTRACE:
78
= note: inside `main` at $DIR/libc_pthread_rwlock_write_write_deadlock_single_thread.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail-dep/shims/sync/libc_pthread_rwlock_write_wrong_owner.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | ... assert_eq!(libc::pthread_rwlock_unlock(lock_copy.0.get() as *mut _),
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9-
= note: BACKTRACE:
9+
= note: BACKTRACE on thread `unnamed-ID`:
1010
= note: inside closure at $DIR/libc_pthread_rwlock_write_wrong_owner.rs:LL:CC
1111

1212
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/both_borrows/retag_data_race_write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn thread_1(p: SendPtr) {
1717
fn thread_2(p: SendPtr) {
1818
let p = p.0;
1919
unsafe {
20-
*p = 5; //~ ERROR: /Data race detected between \(1\) non-atomic (read|write) on thread `<unnamed>` and \(2\) non-atomic write on thread `<unnamed>`/
20+
*p = 5; //~ ERROR: /Data race detected between \(1\) non-atomic (read|write) on thread `unnamed-[0-9]+` and \(2\) non-atomic write on thread `unnamed-[0-9]+`/
2121
}
2222
}
2323

tests/fail/both_borrows/retag_data_race_write.stack.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `<unnamed>` and (2) non-atomic write on thread `<unnamed>` at ALLOC. (2) just happened here
1+
error: Undefined Behavior: Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) non-atomic write on thread `unnamed-ID` at ALLOC. (2) just happened here
22
--> $DIR/retag_data_race_write.rs:LL:CC
33
|
44
LL | *p = 5;
5-
| ^^^^^^ Data race detected between (1) non-atomic write on thread `<unnamed>` and (2) non-atomic write on thread `<unnamed>` at ALLOC. (2) just happened here
5+
| ^^^^^^ Data race detected between (1) non-atomic write on thread `unnamed-ID` and (2) non-atomic write on thread `unnamed-ID` at ALLOC. (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> $DIR/retag_data_race_write.rs:LL:CC
@@ -11,7 +11,7 @@ LL | let _r = &mut *p;
1111
| ^^^^^^^
1212
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1313
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14-
= note: BACKTRACE (of the first span):
14+
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
1515
= note: inside `thread_2` at $DIR/retag_data_race_write.rs:LL:CC
1616
note: inside closure
1717
--> $DIR/retag_data_race_write.rs:LL:CC

tests/fail/both_borrows/retag_data_race_write.tree.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error: Undefined Behavior: Data race detected between (1) non-atomic read on thread `<unnamed>` and (2) non-atomic write on thread `<unnamed>` at ALLOC. (2) just happened here
1+
error: Undefined Behavior: Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) non-atomic write on thread `unnamed-ID` at ALLOC. (2) just happened here
22
--> $DIR/retag_data_race_write.rs:LL:CC
33
|
44
LL | *p = 5;
5-
| ^^^^^^ Data race detected between (1) non-atomic read on thread `<unnamed>` and (2) non-atomic write on thread `<unnamed>` at ALLOC. (2) just happened here
5+
| ^^^^^^ Data race detected between (1) non-atomic read on thread `unnamed-ID` and (2) non-atomic write on thread `unnamed-ID` at ALLOC. (2) just happened here
66
|
77
help: and (1) occurred earlier here
88
--> $DIR/retag_data_race_write.rs:LL:CC
@@ -11,7 +11,7 @@ LL | let _r = &mut *p;
1111
| ^^^^^^^
1212
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
1313
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14-
= note: BACKTRACE (of the first span):
14+
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
1515
= note: inside `thread_2` at $DIR/retag_data_race_write.rs:LL:CC
1616
note: inside closure
1717
--> $DIR/retag_data_race_write.rs:LL:CC

tests/fail/breakpoint.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ error: abnormal termination: trace/breakpoint trap
44
LL | core::intrinsics::breakpoint()
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trace/breakpoint trap
66
|
7+
= note: BACKTRACE:
78
= note: inside `main` at $DIR/breakpoint.rs:LL:CC
89

910
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

tests/fail/data_race/alloc_read_race.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn main() {
3939
let pointer = &*ptr.0;
4040

4141
// Note: could also error due to reading uninitialized memory, but the data-race detector triggers first.
42-
*pointer.load(Ordering::Relaxed) //~ ERROR: Data race detected between (1) creating a new allocation on thread `<unnamed>` and (2) non-atomic read on thread `<unnamed>`
42+
*pointer.load(Ordering::Relaxed) //~ ERROR: Data race detected between (1) creating a new allocation on thread `unnamed-1` and (2) non-atomic read on thread `unnamed-2`
4343
});
4444

4545
j1.join().unwrap();

0 commit comments

Comments
 (0)