Skip to content

Commit 1612452

Browse files
committed
Auto merge of #136943 - GuillaumeGomez:rollup-amtd3mq, r=GuillaumeGomez
Rollup of 10 pull requests Successful merges: - #136758 (tests: `-Copt-level=3` instead of `-O` in assembly tests) - #136761 (tests: `-Copt-level=3` instead of `-O` in codegen tests) - #136784 (Nuke `Buffer` abstraction from `librustdoc`, take 2 💣) - #136838 (Check whole `Unsize` predicate for escaping bound vars) - #136848 (add docs and ut for bootstrap util cache) - #136871 (dev-guide: Link to `t-lang` procedures for new features) - #136890 (Change swap_nonoverlapping from lang to library UB) - #136901 (compiler: give `ExternAbi` truly stable `Hash` and `Ord`) - #136907 (compiler: Make middle errors `pub(crate)` and bury the dead code) - #136916 (use cc archiver as default in `cc2ar`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 03d7ede + 86f6ef0 commit 1612452

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

tests/fail/ptr_swap_nonoverlapping.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! This is a regression test for <https://github.com/rust-lang/miri/issues/4188>: The precondition
2+
//! check in `ptr::swap_nonoverlapping` was incorrectly disabled in Miri.
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();"
4+
//@normalize-stderr-test: "\| +\^+" -> "| ^"
5+
//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
6+
//@normalize-stderr-test: "\n +at [^\n]+" -> ""
7+
//@error-in-other-file: aborted execution
8+
9+
fn main() {
10+
let mut data = 0usize;
11+
let ptr = std::ptr::addr_of_mut!(data);
12+
unsafe {
13+
std::ptr::swap_nonoverlapping(ptr, ptr, 1);
14+
}
15+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
3+
unsafe precondition(s) violated: ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
4+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
5+
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
6+
thread caused non-unwinding panic. aborting.
7+
error: abnormal termination: the program aborted execution
8+
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
9+
|
10+
LL | ABORT();
11+
| ^ the program aborted execution
12+
|
13+
= note: BACKTRACE:
14+
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
15+
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
16+
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
17+
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
18+
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
19+
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
20+
= note: inside `std::ptr::swap_nonoverlapping::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
21+
= note: inside `std::ptr::swap_nonoverlapping::<usize>` at RUSTLIB/core/src/ub_checks.rs:LL:CC
22+
note: inside `main`
23+
--> tests/fail/ptr_swap_nonoverlapping.rs:LL:CC
24+
|
25+
LL | std::ptr::swap_nonoverlapping(ptr, ptr, 1);
26+
| ^
27+
28+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
29+
30+
error: aborting due to 1 previous error
31+

0 commit comments

Comments
 (0)