Skip to content

Commit f34b41a

Browse files
committed
Auto merge of #144028 - samueltardieu:rollup-x6f9h8n, r=samueltardieu
Rollup of 12 pull requests Successful merges: - rust-lang/rust#142936 (rustdoc-json: Structured attributes) - rust-lang/rust#143355 (wrapping shift: remove first bitmask and table) - rust-lang/rust#143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`) - rust-lang/rust#143692 (miri: fix out-of-bounds error for ptrs with negative offsets) - rust-lang/rust#143738 (Move several float tests to floats/mod.rs) - rust-lang/rust#143920 (Make more of codegen_llvm safe) - rust-lang/rust#143921 (Constify `Index` traits) - rust-lang/rust#143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.) - rust-lang/rust#143948 (Update mdbook to 0.4.52) - rust-lang/rust#143957 (tidy: check for invalid file names) - rust-lang/rust#143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`) - rust-lang/rust#143990 (Add LocalKey<Cell>::update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0347ec3 + 6306597 commit f34b41a

File tree

5 files changed

+54
-1
lines changed

5 files changed

+54
-1
lines changed

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_index::IndexVec;
1313
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1414
use rustc_middle::middle::dependency_format::Linkage;
1515
use rustc_middle::middle::exported_symbols::ExportedSymbol;
16-
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
16+
use rustc_middle::ty::layout::{LayoutOf, MaybeResult, TyAndLayout};
1717
use rustc_middle::ty::{self, Binder, FloatTy, FnSig, IntTy, Ty, TyCtxt, UintTy};
1818
use rustc_session::config::CrateType;
1919
use rustc_span::{Span, Symbol};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
let v: Vec<u16> = vec![1, 2];
3+
// This read is also misaligned. We make sure that the OOB message has priority.
4+
let x = unsafe { *v.as_ptr().wrapping_byte_sub(5) }; //~ ERROR: before the beginning of the allocation
5+
panic!("this should never print: {}", x);
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: Undefined Behavior: memory access failed: attempting to access 2 bytes, but got ALLOC-0x5 which points to before the beginning of the allocation
2+
--> tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
3+
|
4+
LL | let x = unsafe { *v.as_ptr().wrapping_byte_sub(5) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
help: ALLOC was allocated here:
10+
--> tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
11+
|
12+
LL | let v: Vec<u16> = vec![1, 2];
13+
| ^^^^^^^^^^
14+
= note: BACKTRACE (of the first span):
15+
= note: inside `main` at tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
16+
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
19+
20+
error: aborting due to 1 previous error
21+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
let v = [0i8; 4];
3+
let x = &v as *const i8;
4+
let x = unsafe { x.wrapping_offset(-1).offset(-1) }; //~ERROR: before the beginning of the allocation
5+
panic!("this should never print: {:?}", x);
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by -1 bytes, but got ALLOC-0x1 which points to before the beginning of the allocation
2+
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
3+
|
4+
LL | let x = unsafe { x.wrapping_offset(-1).offset(-1) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
help: ALLOC was allocated here:
10+
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
11+
|
12+
LL | let v = [0i8; 4];
13+
| ^
14+
= note: BACKTRACE (of the first span):
15+
= note: inside `main` at tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
16+
17+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
18+
19+
error: aborting due to 1 previous error
20+

0 commit comments

Comments
 (0)