From 28dea673bec32b5d59545912f53ad22b8944f3a4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 Jun 2022 08:33:06 -0400 Subject: [PATCH 1/3] rustup --- rust-version | 2 +- src/diagnostics.rs | 4 + src/shims/intrinsics.rs | 122 +++++++++--------- .../data_race/atomic_read_na_write_race1.rs | 4 +- .../atomic_read_na_write_race1.stderr | 4 +- tests/fail/panic/double_panic.stderr | 1 - tests/fail/panic/panic_abort1.stderr | 1 - tests/fail/panic/panic_abort2.stderr | 1 - tests/fail/panic/panic_abort3.stderr | 2 - tests/fail/panic/panic_abort4.stderr | 1 - .../unaligned_pointers/atomic_unaligned.rs | 2 +- .../atomic_unaligned.stderr | 4 +- 12 files changed, 73 insertions(+), 75 deletions(-) diff --git a/rust-version b/rust-version index 5bda09cfdb..4f24d29e34 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -7f08d04d60d03e1a52dae61ce6aa50996898702b +493c960a3e6cdd2e2fbe8b6ea130fadea05f1ab0 diff --git a/src/diagnostics.rs b/src/diagnostics.rs index c762b3d810..95252a1134 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -107,6 +107,10 @@ fn prune_stacktrace<'mir, 'tcx>( // bug in the Rust runtime, we don't prune away every frame. let has_local_frame = stacktrace.iter().any(|frame| ecx.machine.is_local(frame)); if has_local_frame { + // Remove all frames marked with `caller_location` -- that attribute indicates we + // usually want to point at the caller, not them. + stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx)); + // This is part of the logic that `std` uses to select the relevant part of a // backtrace. But here, we only look for __rust_begin_short_backtrace, not // __rust_end_short_backtrace because the end symbol comes from a call to the default diff --git a/src/shims/intrinsics.rs b/src/shims/intrinsics.rs index 8d4da31fd0..fa5a6e9c27 100644 --- a/src/shims/intrinsics.rs +++ b/src/shims/intrinsics.rs @@ -864,95 +864,95 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx } // Atomic operations - "atomic_load" => this.atomic_load(args, dest, AtomicReadOp::SeqCst)?, + "atomic_load_seqcst" => this.atomic_load(args, dest, AtomicReadOp::SeqCst)?, "atomic_load_relaxed" => this.atomic_load(args, dest, AtomicReadOp::Relaxed)?, - "atomic_load_acq" => this.atomic_load(args, dest, AtomicReadOp::Acquire)?, + "atomic_load_acquire" => this.atomic_load(args, dest, AtomicReadOp::Acquire)?, - "atomic_store" => this.atomic_store(args, AtomicWriteOp::SeqCst)?, + "atomic_store_seqcst" => this.atomic_store(args, AtomicWriteOp::SeqCst)?, "atomic_store_relaxed" => this.atomic_store(args, AtomicWriteOp::Relaxed)?, - "atomic_store_rel" => this.atomic_store(args, AtomicWriteOp::Release)?, + "atomic_store_release" => this.atomic_store(args, AtomicWriteOp::Release)?, - "atomic_fence_acq" => this.atomic_fence(args, AtomicFenceOp::Acquire)?, - "atomic_fence_rel" => this.atomic_fence(args, AtomicFenceOp::Release)?, + "atomic_fence_acquire" => this.atomic_fence(args, AtomicFenceOp::Acquire)?, + "atomic_fence_release" => this.atomic_fence(args, AtomicFenceOp::Release)?, "atomic_fence_acqrel" => this.atomic_fence(args, AtomicFenceOp::AcqRel)?, - "atomic_fence" => this.atomic_fence(args, AtomicFenceOp::SeqCst)?, + "atomic_fence_seqcst" => this.atomic_fence(args, AtomicFenceOp::SeqCst)?, - "atomic_singlethreadfence_acq" => this.compiler_fence(args, AtomicFenceOp::Acquire)?, - "atomic_singlethreadfence_rel" => this.compiler_fence(args, AtomicFenceOp::Release)?, + "atomic_singlethreadfence_acquire" => this.compiler_fence(args, AtomicFenceOp::Acquire)?, + "atomic_singlethreadfence_release" => this.compiler_fence(args, AtomicFenceOp::Release)?, "atomic_singlethreadfence_acqrel" => this.compiler_fence(args, AtomicFenceOp::AcqRel)?, - "atomic_singlethreadfence" => this.compiler_fence(args, AtomicFenceOp::SeqCst)?, + "atomic_singlethreadfence_seqcst" => this.compiler_fence(args, AtomicFenceOp::SeqCst)?, - "atomic_xchg" => this.atomic_exchange(args, dest, AtomicRwOp::SeqCst)?, - "atomic_xchg_acq" => this.atomic_exchange(args, dest, AtomicRwOp::Acquire)?, - "atomic_xchg_rel" => this.atomic_exchange(args, dest, AtomicRwOp::Release)?, + "atomic_xchg_seqcst" => this.atomic_exchange(args, dest, AtomicRwOp::SeqCst)?, + "atomic_xchg_acquire" => this.atomic_exchange(args, dest, AtomicRwOp::Acquire)?, + "atomic_xchg_release" => this.atomic_exchange(args, dest, AtomicRwOp::Release)?, "atomic_xchg_acqrel" => this.atomic_exchange(args, dest, AtomicRwOp::AcqRel)?, "atomic_xchg_relaxed" => this.atomic_exchange(args, dest, AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg" => + "atomic_cxchg_seqcst_seqcst" => this.atomic_compare_exchange(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::SeqCst)?, #[rustfmt::skip] - "atomic_cxchg_acq" => + "atomic_cxchg_acquire_acquire" => this.atomic_compare_exchange(args, dest, AtomicRwOp::Acquire, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_cxchg_rel" => + "atomic_cxchg_release_relaxed" => this.atomic_compare_exchange(args, dest, AtomicRwOp::Release, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg_acqrel" => + "atomic_cxchg_acqrel_acquire" => this.atomic_compare_exchange(args, dest, AtomicRwOp::AcqRel, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_cxchg_relaxed" => + "atomic_cxchg_relaxed_relaxed" => this.atomic_compare_exchange(args, dest, AtomicRwOp::Relaxed, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg_acq_failrelaxed" => + "atomic_cxchg_acquire_relaxed" => this.atomic_compare_exchange(args, dest, AtomicRwOp::Acquire, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg_acqrel_failrelaxed" => + "atomic_cxchg_acqrel_relaxed" => this.atomic_compare_exchange(args, dest, AtomicRwOp::AcqRel, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg_failrelaxed" => + "atomic_cxchg_seqcst_relaxed" => this.atomic_compare_exchange(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchg_failacq" => + "atomic_cxchg_seqcst_acquire" => this.atomic_compare_exchange(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_cxchgweak" => + "atomic_cxchgweak_seqcst_seqcst" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::SeqCst)?, #[rustfmt::skip] - "atomic_cxchgweak_acq" => + "atomic_cxchgweak_acquire_acquire" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::Acquire, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_cxchgweak_rel" => + "atomic_cxchgweak_release_relaxed" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::Release, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchgweak_acqrel" => + "atomic_cxchgweak_acqrel_acquire" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::AcqRel, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_cxchgweak_relaxed" => + "atomic_cxchgweak_relaxed_relaxed" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::Relaxed, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchgweak_acq_failrelaxed" => + "atomic_cxchgweak_acquire_relaxed" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::Acquire, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchgweak_acqrel_failrelaxed" => + "atomic_cxchgweak_acqrel_relaxed" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::AcqRel, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchgweak_failrelaxed" => + "atomic_cxchgweak_seqcst_relaxed" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::Relaxed)?, #[rustfmt::skip] - "atomic_cxchgweak_failacq" => + "atomic_cxchgweak_seqcst_acquire" => this.atomic_compare_exchange_weak(args, dest, AtomicRwOp::SeqCst, AtomicReadOp::Acquire)?, #[rustfmt::skip] - "atomic_or" => + "atomic_or_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_or_acq" => + "atomic_or_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_or_rel" => + "atomic_or_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_or_acqrel" => @@ -961,13 +961,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx "atomic_or_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_xor" => + "atomic_xor_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_xor_acq" => + "atomic_xor_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_xor_rel" => + "atomic_xor_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_xor_acqrel" => @@ -976,13 +976,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx "atomic_xor_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_and" => + "atomic_and_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_and_acq" => + "atomic_and_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_and_rel" => + "atomic_and_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_and_acqrel" => @@ -991,13 +991,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx "atomic_and_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_nand" => + "atomic_nand_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_nand_acq" => + "atomic_nand_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_nand_rel" => + "atomic_nand_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_nand_acqrel" => @@ -1006,13 +1006,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx "atomic_nand_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_xadd" => + "atomic_xadd_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_xadd_acq" => + "atomic_xadd_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_xadd_rel" => + "atomic_xadd_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_xadd_acqrel" => @@ -1021,13 +1021,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx "atomic_xadd_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), AtomicRwOp::Relaxed)?, #[rustfmt::skip] - "atomic_xsub" => + "atomic_xsub_seqcst" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), AtomicRwOp::SeqCst)?, #[rustfmt::skip] - "atomic_xsub_acq" => + "atomic_xsub_acquire" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), AtomicRwOp::Acquire)?, #[rustfmt::skip] - "atomic_xsub_rel" => + "atomic_xsub_release" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), AtomicRwOp::Release)?, #[rustfmt::skip] "atomic_xsub_acqrel" => @@ -1035,28 +1035,28 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx #[rustfmt::skip] "atomic_xsub_relaxed" => this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), AtomicRwOp::Relaxed)?, - "atomic_min" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::SeqCst)?, - "atomic_min_acq" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Acquire)?, - "atomic_min_rel" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Release)?, + "atomic_min_seqcst" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::SeqCst)?, + "atomic_min_acquire" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Acquire)?, + "atomic_min_release" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Release)?, "atomic_min_acqrel" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::AcqRel)?, "atomic_min_relaxed" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Relaxed)?, - "atomic_max" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::SeqCst)?, - "atomic_max_acq" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Acquire)?, - "atomic_max_rel" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Release)?, + "atomic_max_seqcst" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::SeqCst)?, + "atomic_max_acquire" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Acquire)?, + "atomic_max_release" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Release)?, "atomic_max_acqrel" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::AcqRel)?, "atomic_max_relaxed" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Relaxed)?, - "atomic_umin" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::SeqCst)?, - "atomic_umin_acq" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Acquire)?, - "atomic_umin_rel" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Release)?, + "atomic_umin_seqcst" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::SeqCst)?, + "atomic_umin_acquire" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Acquire)?, + "atomic_umin_release" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Release)?, "atomic_umin_acqrel" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::AcqRel)?, "atomic_umin_relaxed" => this.atomic_op(args, dest, AtomicOp::Min, AtomicRwOp::Relaxed)?, - "atomic_umax" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::SeqCst)?, - "atomic_umax_acq" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Acquire)?, - "atomic_umax_rel" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Release)?, + "atomic_umax_seqcst" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::SeqCst)?, + "atomic_umax_acquire" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Acquire)?, + "atomic_umax_release" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::Release)?, "atomic_umax_acqrel" => this.atomic_op(args, dest, AtomicOp::Max, AtomicRwOp::AcqRel)?, "atomic_umax_relaxed" => diff --git a/tests/fail/data_race/atomic_read_na_write_race1.rs b/tests/fail/data_race/atomic_read_na_write_race1.rs index 5131e33fef..5cf2f26bf1 100644 --- a/tests/fail/data_race/atomic_read_na_write_race1.rs +++ b/tests/fail/data_race/atomic_read_na_write_race1.rs @@ -1,7 +1,7 @@ // ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] -use std::intrinsics::atomic_load; +use std::intrinsics; use std::sync::atomic::AtomicUsize; use std::thread::spawn; @@ -22,7 +22,7 @@ pub fn main() { let j2 = spawn(move || { //Equivalent to: (&*c.0).load(Ordering::SeqCst) - atomic_load(c.0 as *mut usize) //~ ERROR Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) + 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) }); j1.join().unwrap(); diff --git a/tests/fail/data_race/atomic_read_na_write_race1.stderr b/tests/fail/data_race/atomic_read_na_write_race1.stderr index 80e79eb553..51cdb23950 100644 --- a/tests/fail/data_race/atomic_read_na_write_race1.stderr +++ b/tests/fail/data_race/atomic_read_na_write_race1.stderr @@ -1,8 +1,8 @@ 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) --> $DIR/atomic_read_na_write_race1.rs:LL:CC | -LL | atomic_load(c.0 as *mut usize) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/panic/double_panic.stderr b/tests/fail/panic/double_panic.stderr index 0dbd68c098..c88dfd39e1 100644 --- a/tests/fail/panic/double_panic.stderr +++ b/tests/fail/panic/double_panic.stderr @@ -75,7 +75,6 @@ LL | ABORT(); = note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC = 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 - = note: inside `std::rt::begin_panic::<&str>` at RUSTLIB/std/src/panicking.rs:LL:CC note: inside `::drop` at RUSTLIB/std/src/panic.rs:LL:CC --> $DIR/double_panic.rs:LL:CC | diff --git a/tests/fail/panic/panic_abort1.stderr b/tests/fail/panic/panic_abort1.stderr index 9610a16128..808fccaaec 100644 --- a/tests/fail/panic/panic_abort1.stderr +++ b/tests/fail/panic/panic_abort1.stderr @@ -12,7 +12,6 @@ LL | ABORT(); = note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC = 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 - = note: inside `std::rt::begin_panic::<&str>` at RUSTLIB/std/src/panicking.rs:LL:CC note: inside `main` at RUSTLIB/std/src/panic.rs:LL:CC --> $DIR/panic_abort1.rs:LL:CC | diff --git a/tests/fail/panic/panic_abort2.stderr b/tests/fail/panic/panic_abort2.stderr index 0c446323a7..9b86dc92f7 100644 --- a/tests/fail/panic/panic_abort2.stderr +++ b/tests/fail/panic/panic_abort2.stderr @@ -13,7 +13,6 @@ LL | ABORT(); = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC = 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 = note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC note: inside `main` at RUSTLIB/std/src/panic.rs:LL:CC --> $DIR/panic_abort2.rs:LL:CC | diff --git a/tests/fail/panic/panic_abort3.stderr b/tests/fail/panic/panic_abort3.stderr index 2d7b576372..2bb50d55bf 100644 --- a/tests/fail/panic/panic_abort3.stderr +++ b/tests/fail/panic/panic_abort3.stderr @@ -13,8 +13,6 @@ LL | ABORT(); = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC = 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 = note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC - = note: inside `core::panicking::panic` at RUSTLIB/core/src/panicking.rs:LL:CC note: inside `main` at RUSTLIB/core/src/panic.rs:LL:CC --> $DIR/panic_abort3.rs:LL:CC | diff --git a/tests/fail/panic/panic_abort4.stderr b/tests/fail/panic/panic_abort4.stderr index b0b1124810..8ab5793016 100644 --- a/tests/fail/panic/panic_abort4.stderr +++ b/tests/fail/panic/panic_abort4.stderr @@ -13,7 +13,6 @@ LL | ABORT(); = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC = 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 = note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC - = note: inside `std::rt::panic_fmt` at RUSTLIB/core/src/panicking.rs:LL:CC note: inside `main` at RUSTLIB/core/src/panic.rs:LL:CC --> $DIR/panic_abort4.rs:LL:CC | diff --git a/tests/fail/unaligned_pointers/atomic_unaligned.rs b/tests/fail/unaligned_pointers/atomic_unaligned.rs index 7e0704ac6f..74dd0b415c 100644 --- a/tests/fail/unaligned_pointers/atomic_unaligned.rs +++ b/tests/fail/unaligned_pointers/atomic_unaligned.rs @@ -7,7 +7,7 @@ fn main() { let z = [0u32; 2]; let zptr = &z as *const _ as *const u64; unsafe { - ::std::intrinsics::atomic_load(zptr); + ::std::intrinsics::atomic_load_seqcst(zptr); //~^ERROR accessing memory with alignment 4, but alignment 8 is required } } diff --git a/tests/fail/unaligned_pointers/atomic_unaligned.stderr b/tests/fail/unaligned_pointers/atomic_unaligned.stderr index f56e6612fb..e3b7f4cdbc 100644 --- a/tests/fail/unaligned_pointers/atomic_unaligned.stderr +++ b/tests/fail/unaligned_pointers/atomic_unaligned.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required --> $DIR/atomic_unaligned.rs:LL:CC | -LL | ::std::intrinsics::atomic_load(zptr); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required +LL | ::std::intrinsics::atomic_load_seqcst(zptr); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required | = help: this usually indicates that your program performed an invalid operation and caused Undefined Behavior = help: but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives From ea8dba411bdfc9d1ea38a2c9b89e91250137ad29 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 Jun 2022 09:31:11 -0400 Subject: [PATCH 2/3] improve atomics test coverage --- tests/pass/atomic.rs | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tests/pass/atomic.rs b/tests/pass/atomic.rs index 9a9e852ecf..07b5d5f3d2 100644 --- a/tests/pass/atomic.rs +++ b/tests/pass/atomic.rs @@ -2,7 +2,7 @@ use std::sync::atomic::{compiler_fence, fence, AtomicBool, AtomicIsize, AtomicU6 fn main() { atomic_bool(); - atomic_isize(); + atomic_all_ops(); atomic_u64(); atomic_fences(); weak_sometimes_fails(); @@ -25,6 +25,7 @@ fn atomic_bool() { assert_eq!(*ATOMIC.get_mut(), false); } } + // There isn't a trait to use to make this generic, so just use a macro macro_rules! compare_exchange_weak_loop { ($atom:expr, $from:expr, $to:expr, $succ_order:expr, $fail_order:expr) => { @@ -39,10 +40,40 @@ macro_rules! compare_exchange_weak_loop { } }; } -fn atomic_isize() { + +/// Make sure we can handle all the intrinsics +fn atomic_all_ops() { static ATOMIC: AtomicIsize = AtomicIsize::new(0); + static ATOMIC_UNSIGNED: AtomicU64 = AtomicU64::new(0); + + + // loads + for o in [Relaxed, Acquire, SeqCst] { + ATOMIC.load(o); + } - // Make sure trans can emit all the intrinsics correctly + // stores + for o in [Relaxed, Release, SeqCst] { + ATOMIC.store(1, o); + } + + // most RMWs + for o in [Relaxed, Release, Acquire, AcqRel, SeqCst] { + ATOMIC.swap(0, o); + ATOMIC.fetch_or(0, o); + ATOMIC.fetch_xor(0, o); + ATOMIC.fetch_and(0, o); + ATOMIC.fetch_nand(0, o); + ATOMIC.fetch_add(0, o); + ATOMIC.fetch_sub(0, o); + ATOMIC.fetch_min(0, o); + ATOMIC.fetch_max(0, o); + ATOMIC_UNSIGNED.fetch_min(0, o); + ATOMIC_UNSIGNED.fetch_max(0, o); + } + + // RMWs with deparate failure ordering + ATOMIC.store(0, SeqCst); assert_eq!(ATOMIC.compare_exchange(0, 1, Relaxed, Relaxed), Ok(0)); assert_eq!(ATOMIC.compare_exchange(0, 2, Acquire, Relaxed), Err(1)); assert_eq!(ATOMIC.compare_exchange(0, 1, Release, Relaxed), Err(1)); @@ -59,7 +90,6 @@ fn atomic_isize() { assert_eq!(ATOMIC.compare_exchange_weak(0, 1, Release, Relaxed), Err(1)); compare_exchange_weak_loop!(ATOMIC, 1, 0, AcqRel, Relaxed); assert_eq!(ATOMIC.load(Relaxed), 0); - ATOMIC.compare_exchange_weak(0, 1, AcqRel, Relaxed).ok(); ATOMIC.compare_exchange_weak(0, 1, SeqCst, Relaxed).ok(); ATOMIC.compare_exchange_weak(0, 1, Acquire, Acquire).ok(); ATOMIC.compare_exchange_weak(0, 1, AcqRel, Acquire).ok(); From f389d46b04c42c3f85ceeb182eabeac94a392b7b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 29 Jun 2022 09:33:12 -0400 Subject: [PATCH 3/3] also prune caller_location frames when backtrace=off --- src/diagnostics.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 95252a1134..55598c19ef 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -96,6 +96,9 @@ fn prune_stacktrace<'mir, 'tcx>( ) -> (Vec>, bool) { match ecx.machine.backtrace_style { BacktraceStyle::Off => { + // Remove all frames marked with `caller_location` -- that attribute indicates we + // usually want to point at the caller, not them. + stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*ecx.tcx)); // Retain one frame so that we can print a span for the error itself stacktrace.truncate(1); (stacktrace, false)