Skip to content

Commit 63d6605

Browse files
committed
Auto merge of #2281 - RalfJung:rustup, r=RalfJung
Rustup Fix our stacktrace after rust-lang/rust#98549. Now we can control whether `caller_location` should be pruned!
2 parents 29b1cc7 + 839c120 commit 63d6605

13 files changed

+122
-79
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7f08d04d60d03e1a52dae61ce6aa50996898702b
1+
493c960a3e6cdd2e2fbe8b6ea130fadea05f1ab0

src/diagnostics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ fn prune_stacktrace<'mir, 'tcx>(
9696
) -> (Vec<FrameInfo<'tcx>>, bool) {
9797
match ecx.machine.backtrace_style {
9898
BacktraceStyle::Off => {
99+
// Remove all frames marked with `caller_location` -- that attribute indicates we
100+
// usually want to point at the caller, not them.
101+
stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx));
99102
// Retain one frame so that we can print a span for the error itself
100103
stacktrace.truncate(1);
101104
(stacktrace, false)
@@ -107,6 +110,10 @@ fn prune_stacktrace<'mir, 'tcx>(
107110
// bug in the Rust runtime, we don't prune away every frame.
108111
let has_local_frame = stacktrace.iter().any(|frame| ecx.machine.is_local(frame));
109112
if has_local_frame {
113+
// Remove all frames marked with `caller_location` -- that attribute indicates we
114+
// usually want to point at the caller, not them.
115+
stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx));
116+
110117
// This is part of the logic that `std` uses to select the relevant part of a
111118
// backtrace. But here, we only look for __rust_begin_short_backtrace, not
112119
// __rust_end_short_backtrace because the end symbol comes from a call to the default

src/shims/intrinsics.rs

Lines changed: 74 additions & 61 deletions
Large diffs are not rendered by default.

tests/fail/data_race/atomic_read_na_write_race1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ignore-windows: Concurrency on Windows is not supported yet.
22
#![feature(core_intrinsics)]
33

4-
use std::intrinsics::atomic_load;
4+
use std::intrinsics;
55
use std::sync::atomic::AtomicUsize;
66
use std::thread::spawn;
77

@@ -22,7 +22,7 @@ pub fn main() {
2222

2323
let j2 = spawn(move || {
2424
//Equivalent to: (&*c.0).load(Ordering::SeqCst)
25-
atomic_load(c.0 as *mut usize) //~ ERROR Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1)
25+
intrinsics::atomic_load_seqcst(c.0 as *mut usize) //~ ERROR Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1)
2626
});
2727

2828
j1.join().unwrap();

tests/fail/data_race/atomic_read_na_write_race1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
22
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
33
|
4-
LL | atomic_load(c.0 as *mut usize)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
4+
LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
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

tests/fail/panic/double_panic.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ LL | ABORT();
7575
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
7676
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
7777
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
78-
= note: inside `std::rt::begin_panic::<&str>` at RUSTLIB/std/src/panicking.rs:LL:CC
7978
note: inside `<Foo as std::ops::Drop>::drop` at RUSTLIB/std/src/panic.rs:LL:CC
8079
--> $DIR/double_panic.rs:LL:CC
8180
|

tests/fail/panic/panic_abort1.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ LL | ABORT();
1212
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
1313
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
1414
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::rt::begin_panic<&str>::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
15-
= note: inside `std::rt::begin_panic::<&str>` at RUSTLIB/std/src/panicking.rs:LL:CC
1615
note: inside `main` at RUSTLIB/std/src/panic.rs:LL:CC
1716
--> $DIR/panic_abort1.rs:LL:CC
1817
|

tests/fail/panic/panic_abort2.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ LL | ABORT();
1313
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
1414
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
1515
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
16-
= note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC
1716
note: inside `main` at RUSTLIB/std/src/panic.rs:LL:CC
1817
--> $DIR/panic_abort2.rs:LL:CC
1918
|

tests/fail/panic/panic_abort3.stderr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ LL | ABORT();
1313
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
1414
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
1515
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
16-
= note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC
17-
= note: inside `core::panicking::panic` at RUSTLIB/core/src/panicking.rs:LL:CC
1816
note: inside `main` at RUSTLIB/core/src/panic.rs:LL:CC
1917
--> $DIR/panic_abort3.rs:LL:CC
2018
|

tests/fail/panic/panic_abort4.stderr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ LL | ABORT();
1313
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
1414
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
1515
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
16-
= note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC
1716
note: inside `main` at RUSTLIB/core/src/panic.rs:LL:CC
1817
--> $DIR/panic_abort4.rs:LL:CC
1918
|

0 commit comments

Comments
 (0)