mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 05:03:47 +00:00
improve dangling/oob errors and make them more uniform
This commit is contained in:
parent
5b38b149dc
commit
f8ebe8d783
@ -45,9 +45,9 @@ const_eval_copy_nonoverlapping_overlapping =
|
||||
`copy_nonoverlapping` called on overlapping ranges
|
||||
|
||||
const_eval_dangling_int_pointer =
|
||||
{$bad_pointer_message}: {$pointer} is a dangling pointer (it has no provenance)
|
||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got {$pointer} which is a dangling pointer (it has no provenance)
|
||||
const_eval_dangling_null_pointer =
|
||||
{$bad_pointer_message}: null pointer is a dangling pointer (it has no provenance)
|
||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got a null pointer
|
||||
|
||||
const_eval_dangling_ptr_in_final = encountered dangling pointer in final value of {const_eval_intern_kind}
|
||||
const_eval_dead_local =
|
||||
@ -87,6 +87,13 @@ const_eval_error = {$error_kind ->
|
||||
const_eval_exact_div_has_remainder =
|
||||
exact_div: {$a} cannot be divided by {$b} without remainder
|
||||
|
||||
const_eval_expected_inbounds_pointer =
|
||||
expected {$inbounds_size ->
|
||||
[0] a pointer to some allocation
|
||||
[1] a pointer to 1 byte of memory
|
||||
*[x] a pointer to {$inbounds_size} bytes of memory
|
||||
}
|
||||
|
||||
const_eval_extern_static =
|
||||
cannot access extern static ({$did})
|
||||
const_eval_extern_type_field = `extern type` field does not have a known offset
|
||||
@ -265,10 +272,16 @@ const_eval_pointer_arithmetic_overflow =
|
||||
overflowing in-bounds pointer arithmetic
|
||||
const_eval_pointer_arithmetic_test = out-of-bounds pointer arithmetic
|
||||
const_eval_pointer_out_of_bounds =
|
||||
{$bad_pointer_message}: {$alloc_id} has size {$alloc_size}, so pointer to {$ptr_size} {$ptr_size ->
|
||||
[1] byte
|
||||
*[many] bytes
|
||||
} starting at offset {$ptr_offset} is out-of-bounds
|
||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got {$pointer} {$ptr_offset_is_neg ->
|
||||
[true] which points to before the beginning of the allocation
|
||||
*[false] {$alloc_size_minus_ptr_offset ->
|
||||
[0] which is at or beyond the end of the allocation of size {$alloc_size ->
|
||||
[1] 1 byte
|
||||
*[x] {$alloc_size} bytes
|
||||
}
|
||||
*[x] and there are only {$alloc_size_minus_ptr_offset} bytes starting at that pointer
|
||||
}
|
||||
}
|
||||
const_eval_pointer_use_after_free =
|
||||
{$bad_pointer_message}: {$alloc_id} has been freed, so this pointer is dangling
|
||||
const_eval_ptr_as_bytes_1 =
|
||||
@ -466,5 +479,3 @@ const_eval_write_through_immutable_pointer =
|
||||
|
||||
const_eval_write_to_read_only =
|
||||
writing to {$allocation} which is read-only
|
||||
const_eval_zst_pointer_out_of_bounds =
|
||||
{$bad_pointer_message}: {$alloc_id} has size {$alloc_size}, so pointer at offset {$ptr_offset} is out-of-bounds
|
||||
|
@ -7,9 +7,9 @@ use rustc_errors::{
|
||||
use rustc_hir::ConstContext;
|
||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::mir::interpret::{
|
||||
CheckInAllocMsg, ExpectedKind, InterpError, InvalidMetaKind, InvalidProgramInfo, Misalignment,
|
||||
PointerKind, ResourceExhaustionInfo, UndefinedBehaviorInfo, UnsupportedOpInfo,
|
||||
ValidationErrorInfo,
|
||||
CheckInAllocMsg, CtfeProvenance, ExpectedKind, InterpError, InvalidMetaKind,
|
||||
InvalidProgramInfo, Misalignment, Pointer, PointerKind, ResourceExhaustionInfo,
|
||||
UndefinedBehaviorInfo, UnsupportedOpInfo, ValidationErrorInfo,
|
||||
};
|
||||
use rustc_middle::ty::{self, Mutability, Ty};
|
||||
use rustc_span::Span;
|
||||
@ -488,10 +488,9 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
||||
InvalidMeta(InvalidMetaKind::TooBig) => const_eval_invalid_meta,
|
||||
UnterminatedCString(_) => const_eval_unterminated_c_string,
|
||||
PointerUseAfterFree(_, _) => const_eval_pointer_use_after_free,
|
||||
PointerOutOfBounds { ptr_size: Size::ZERO, .. } => const_eval_zst_pointer_out_of_bounds,
|
||||
PointerOutOfBounds { .. } => const_eval_pointer_out_of_bounds,
|
||||
DanglingIntPointer(0, _) => const_eval_dangling_null_pointer,
|
||||
DanglingIntPointer(_, _) => const_eval_dangling_int_pointer,
|
||||
DanglingIntPointer { addr: 0, .. } => const_eval_dangling_null_pointer,
|
||||
DanglingIntPointer { .. } => const_eval_dangling_int_pointer,
|
||||
AlignmentCheckFailed { .. } => const_eval_alignment_check_failed,
|
||||
WriteToReadOnly(_) => const_eval_write_to_read_only,
|
||||
DerefFunctionPointer(_) => const_eval_deref_function_pointer,
|
||||
@ -573,18 +572,33 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
||||
diag.arg("alloc_id", alloc_id)
|
||||
.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
||||
}
|
||||
PointerOutOfBounds { alloc_id, alloc_size, ptr_offset, ptr_size, msg } => {
|
||||
diag.arg("alloc_id", alloc_id)
|
||||
.arg("alloc_size", alloc_size.bytes())
|
||||
.arg("ptr_offset", ptr_offset)
|
||||
.arg("ptr_size", ptr_size.bytes())
|
||||
PointerOutOfBounds { alloc_id, alloc_size, ptr_offset, inbounds_size, msg } => {
|
||||
diag.arg("alloc_size", alloc_size.bytes())
|
||||
.arg("inbounds_size", inbounds_size.bytes())
|
||||
.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
||||
diag.arg(
|
||||
"pointer",
|
||||
Pointer::new(
|
||||
Some(CtfeProvenance::from(alloc_id)),
|
||||
Size::from_bytes(ptr_offset as u64),
|
||||
)
|
||||
.to_string(),
|
||||
);
|
||||
diag.arg("ptr_offset_is_neg", ptr_offset < 0);
|
||||
diag.arg(
|
||||
"alloc_size_minus_ptr_offset",
|
||||
alloc_size.bytes().saturating_sub(ptr_offset as u64),
|
||||
);
|
||||
}
|
||||
DanglingIntPointer(ptr, msg) => {
|
||||
if ptr != 0 {
|
||||
diag.arg("pointer", format!("{ptr:#x}[noalloc]"));
|
||||
DanglingIntPointer { addr, inbounds_size, msg } => {
|
||||
if addr != 0 {
|
||||
diag.arg(
|
||||
"pointer",
|
||||
Pointer::<Option<CtfeProvenance>>::from_addr_invalid(addr).to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
diag.arg("inbounds_size", inbounds_size.bytes());
|
||||
diag.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
||||
}
|
||||
AlignmentCheckFailed(Misalignment { required, has }, msg) => {
|
||||
|
@ -459,7 +459,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
Ok(match self.ptr_try_get_alloc_id(ptr) {
|
||||
Err(addr) => {
|
||||
// We couldn't get a proper allocation.
|
||||
throw_ub!(DanglingIntPointer(addr, msg));
|
||||
throw_ub!(DanglingIntPointer { addr, inbounds_size: size, msg });
|
||||
}
|
||||
Ok((alloc_id, offset, prov)) => {
|
||||
let (alloc_size, _alloc_align, ret_val) = alloc_size(alloc_id, offset, prov)?;
|
||||
@ -470,7 +470,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
alloc_id,
|
||||
alloc_size,
|
||||
ptr_offset: self.target_usize_to_isize(offset.bytes()),
|
||||
ptr_size: size,
|
||||
inbounds_size: size,
|
||||
msg,
|
||||
})
|
||||
}
|
||||
@ -1443,7 +1443,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
||||
ptr: Pointer<Option<M::Provenance>>,
|
||||
) -> InterpResult<'tcx, (AllocId, Size, M::ProvenanceExtra)> {
|
||||
self.ptr_try_get_alloc_id(ptr).map_err(|offset| {
|
||||
err_ub!(DanglingIntPointer(offset, CheckInAllocMsg::InboundsTest)).into()
|
||||
err_ub!(DanglingIntPointer {
|
||||
addr: offset,
|
||||
// We don't know the actually required size.
|
||||
inbounds_size: Size::ZERO,
|
||||
msg: CheckInAllocMsg::InboundsTest
|
||||
})
|
||||
.into()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
|
||||
try_validation!(
|
||||
self.ecx.get_ptr_vtable_ty(vtable, Some(data)),
|
||||
self.path,
|
||||
Ub(DanglingIntPointer(..) | InvalidVTablePointer(..)) =>
|
||||
Ub(DanglingIntPointer{ .. } | InvalidVTablePointer(..)) =>
|
||||
InvalidVTablePtr { value: format!("{vtable}") },
|
||||
Ub(InvalidVTableTrait { expected_trait, vtable_trait }) => {
|
||||
InvalidMetaWrongTrait { expected_trait, vtable_trait: *vtable_trait }
|
||||
@ -405,8 +405,8 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
|
||||
CheckInAllocMsg::InboundsTest, // will anyway be replaced by validity message
|
||||
),
|
||||
self.path,
|
||||
Ub(DanglingIntPointer(0, _)) => NullPtr { ptr_kind },
|
||||
Ub(DanglingIntPointer(i, _)) => DanglingPtrNoProvenance {
|
||||
Ub(DanglingIntPointer { addr: 0, .. }) => NullPtr { ptr_kind },
|
||||
Ub(DanglingIntPointer { addr: i, .. }) => DanglingPtrNoProvenance {
|
||||
ptr_kind,
|
||||
// FIXME this says "null pointer" when null but we need translate
|
||||
pointer: format!("{}", Pointer::<Option<AllocId>>::from_addr_invalid(*i))
|
||||
@ -605,7 +605,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
|
||||
let _fn = try_validation!(
|
||||
self.ecx.get_ptr_fn(ptr),
|
||||
self.path,
|
||||
Ub(DanglingIntPointer(..) | InvalidFunctionPointer(..)) =>
|
||||
Ub(DanglingIntPointer{ .. } | InvalidFunctionPointer(..)) =>
|
||||
InvalidFnPtr { value: format!("{ptr}") },
|
||||
);
|
||||
// FIXME: Check if the signature matches
|
||||
|
@ -329,16 +329,21 @@ pub enum UndefinedBehaviorInfo<'tcx> {
|
||||
/// Using a pointer after it got freed.
|
||||
PointerUseAfterFree(AllocId, CheckInAllocMsg),
|
||||
/// Used a pointer outside the bounds it is valid for.
|
||||
/// (If `ptr_size > 0`, determines the size of the memory range that was expected to be in-bounds.)
|
||||
PointerOutOfBounds {
|
||||
alloc_id: AllocId,
|
||||
alloc_size: Size,
|
||||
ptr_offset: i64,
|
||||
ptr_size: Size,
|
||||
/// The size of the memory range that was expected to be in-bounds.
|
||||
inbounds_size: Size,
|
||||
msg: CheckInAllocMsg,
|
||||
},
|
||||
/// Using an integer as a pointer in the wrong way.
|
||||
DanglingIntPointer(u64, CheckInAllocMsg),
|
||||
DanglingIntPointer {
|
||||
addr: u64,
|
||||
/// The size of the memory range that was expected to be in-bounds (or 0 if we don't know).
|
||||
inbounds_size: Size,
|
||||
msg: CheckInAllocMsg,
|
||||
},
|
||||
/// Used a pointer with bad alignment.
|
||||
AlignmentCheckFailed(Misalignment, CheckAlignMsg),
|
||||
/// Writing to read-only memory.
|
||||
|
@ -180,9 +180,12 @@ impl Provenance for CtfeProvenance {
|
||||
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// Print AllocId.
|
||||
fmt::Debug::fmt(&ptr.provenance.alloc_id(), f)?; // propagates `alternate` flag
|
||||
// Print offset only if it is non-zero.
|
||||
if ptr.offset.bytes() > 0 {
|
||||
write!(f, "+{:#x}", ptr.offset.bytes())?;
|
||||
// Print offset only if it is non-zero. Print it signed.
|
||||
let signed_offset = ptr.offset.bytes() as i64;
|
||||
if signed_offset > 0 {
|
||||
write!(f, "+{:#x}", signed_offset)?;
|
||||
} else if signed_offset < 0 {
|
||||
write!(f, "-{:#x}", signed_offset.unsigned_abs())?;
|
||||
}
|
||||
// Print immutable status.
|
||||
if ptr.provenance.immutable() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 128, so pointer to 129 bytes starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 129 bytes of memory, but got ALLOC and there are only 128 bytes starting at that pointer
|
||||
--> $DIR/affinity.rs:LL:CC
|
||||
|
|
||||
LL | let err = unsafe { sched_setaffinity(PID, size_of::<cpu_set_t>() + 1, &cpuset) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has size 128, so pointer to 129 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 129 bytes of memory, but got ALLOC and there are only 128 bytes starting at that pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -3,6 +3,6 @@ use std::ptr;
|
||||
// null is explicitly called out as UB in the C docs.
|
||||
fn main() {
|
||||
unsafe {
|
||||
libc::memchr(ptr::null(), 0, 0); //~ERROR: dangling
|
||||
libc::memchr(ptr::null(), 0, 0); //~ERROR: null pointer
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
--> $DIR/memchr_null.rs:LL:CC
|
||||
|
|
||||
LL | libc::memchr(ptr::null(), 0, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -3,6 +3,6 @@ use std::ptr;
|
||||
// null is explicitly called out as UB in the C docs.
|
||||
fn main() {
|
||||
unsafe {
|
||||
libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: dangling
|
||||
libc::memcmp(ptr::null(), ptr::null(), 0); //~ERROR: null pointer
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
--> $DIR/memcmp_null.rs:LL:CC
|
||||
|
|
||||
LL | libc::memcmp(ptr::null(), ptr::null(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/memcmp_zero.rs:LL:CC
|
||||
|
|
||||
LL | libc::memcmp(ptr.cast(), ptr.cast(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got 0x17[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/memcpy_zero.rs:LL:CC
|
||||
|
|
||||
LL | libc::memcpy(to.cast(), from.cast(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x17[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x17[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -6,6 +6,6 @@ use std::ptr;
|
||||
// null is explicitly called out as UB in the C docs.
|
||||
fn main() {
|
||||
unsafe {
|
||||
libc::memrchr(ptr::null(), 0, 0); //~ERROR: dangling
|
||||
libc::memrchr(ptr::null(), 0, 0); //~ERROR: null pointer
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
--> $DIR/memrchr_null.rs:LL:CC
|
||||
|
|
||||
LL | libc::memrchr(ptr::null(), 0, 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,6 +1,6 @@
|
||||
//@revisions: stack tree
|
||||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
//@error-in-other-file: pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
//@error-in-other-file: expected a pointer to 4 bytes of memory
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: ALLOC has size 2, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC and there are only 2 bytes starting at that pointer
|
||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||
|
|
||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: ALLOC has size 2, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC and there are only 2 bytes starting at that pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: ALLOC has size 2, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC and there are only 2 bytes starting at that pointer
|
||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||
|
|
||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: ALLOC has size 2, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC and there are only 2 bytes starting at that pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x4[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||
|
|
||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x4[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x4[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||
|
|
||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: 0x4[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x10[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/dangling_pointer_to_raw_pointer.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { &(*x).0 as *const i32 }
|
||||
| ^^^^^^^ out-of-bounds pointer use: 0x10[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x10[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/deref-invalid-ptr.rs:LL:CC
|
||||
|
|
||||
LL | let _y = unsafe { &*x as *const u32 };
|
||||
| ^^^ out-of-bounds pointer use: 0x10[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: null pointer is a dangling pointer
|
||||
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: null pointer
|
||||
panic!("this should never print: {}", x);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
||||
--> $DIR/null_pointer_deref.rs:LL:CC
|
||||
|
|
||||
LL | let x: i32 = unsafe { *std::ptr::null() };
|
||||
| ^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
#[allow(deref_nullptr)]
|
||||
fn main() {
|
||||
unsafe { *std::ptr::null_mut() = 0i32 }; //~ ERROR: null pointer is a dangling pointer
|
||||
unsafe { *std::ptr::null_mut() = 0i32 }; //~ ERROR: null pointer
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
||||
--> $DIR/null_pointer_write.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { *std::ptr::null_mut() = 0i32 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC and there are only 4 bytes starting at that pointer
|
||||
--> $DIR/out_of_bounds_project.rs:LL:CC
|
||||
|
|
||||
LL | let _field = addr_of!((*ptr).2);
|
||||
| ^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC and there are only 4 bytes starting at that pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let v: Vec<u16> = vec![1, 2];
|
||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
||||
let x = unsafe { *v.as_ptr().wrapping_byte_add(5) }; //~ ERROR: out-of-bounds
|
||||
let x = unsafe { *v.as_ptr().wrapping_byte_add(5) }; //~ ERROR: expected a pointer to 2 bytes of memory
|
||||
panic!("this should never print: {}", x);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 4, so pointer to 2 bytes starting at offset 5 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 2 bytes of memory, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||
--> $DIR/out_of_bounds_read.rs:LL:CC
|
||||
|
|
||||
LL | let x = unsafe { *v.as_ptr().wrapping_byte_add(5) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has size 4, so pointer to 2 bytes starting at offset 5 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 2 bytes of memory, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
= 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
let mut v: Vec<u16> = vec![1, 2];
|
||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
||||
unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 }; //~ ERROR: out-of-bounds
|
||||
unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 }; //~ ERROR: expected a pointer to 2 bytes of memory
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 4, so pointer to 2 bytes starting at offset 5 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 2 bytes of memory, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||
--> $DIR/out_of_bounds_write.rs:LL:CC
|
||||
|
|
||||
LL | unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has size 4, so pointer to 2 bytes starting at offset 5 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 2 bytes of memory, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/storage_dead_dangling.rs:LL:CC
|
||||
|
|
||||
LL | let _ref = unsafe { &mut *(LEAK as *mut i32) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: 0x2c[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/wild_pointer_deref.rs:LL:CC
|
||||
|
|
||||
LL | let x = unsafe { *p };
|
||||
| ^^ memory access failed: 0x2c[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/cast_int_to_fn_ptr.rs:LL:CC
|
||||
|
|
||||
LL | g(42)
|
||||
| ^^^^^ out-of-bounds pointer use: 0x2a[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -2,6 +2,6 @@ fn main() {
|
||||
let v = [0i8; 4];
|
||||
let x = &v as *const i8;
|
||||
// The error is inside another function, so we cannot match it by line
|
||||
let x = unsafe { x.offset(5) }; //~ERROR: pointer to 5 bytes starting at offset 0 is out-of-bounds
|
||||
let x = unsafe { x.offset(5) }; //~ERROR: expected a pointer to 5 bytes of memory
|
||||
panic!("this should never print: {:?}", x);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 5 bytes of memory, but got ALLOC and there are only 4 bytes starting at that pointer
|
||||
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
|
||||
|
|
||||
LL | let x = unsafe { x.offset(5) };
|
||||
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 5 bytes of memory, but got ALLOC and there are only 4 bytes starting at that pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,6 +1,6 @@
|
||||
fn main() {
|
||||
let v = [0i8; 4];
|
||||
let x = &v as *const i8;
|
||||
let x = unsafe { x.offset(-1) }; //~ERROR: pointer to 1 byte starting at offset -1 is out-of-bounds
|
||||
let x = unsafe { x.offset(-1) }; //~ERROR: expected a pointer to 1 byte of memory
|
||||
panic!("this should never print: {:?}", x);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC-0x1 which points to before the beginning of the allocation
|
||||
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
|
||||
|
|
||||
LL | let x = unsafe { x.offset(-1) };
|
||||
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
|
||||
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC-0x1 which points to before the beginning of the allocation
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds `offset_from`: 0xa[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds `offset_from`: expected a pointer to 1 byte of memory, but got 0xa[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_offset_from_different_ints.rs:LL:CC
|
||||
|
|
||||
LL | let _ = p1.byte_offset_from(p2);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: 0xa[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to 1 byte of memory, but got 0xa[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_offset_int_plus_int.rs:LL:CC
|
||||
|
|
||||
LL | let _val = (1 as *mut u8).offset(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,4 +1,5 @@
|
||||
//@compile-flags: -Zmiri-permissive-provenance
|
||||
//@normalize-stderr-test: "to \d+ bytes of memory" -> "to $$BYTES bytes of memory"
|
||||
|
||||
fn main() {
|
||||
let ptr = Box::into_raw(Box::new(0u32));
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_offset_int_plus_ptr.rs:LL:CC
|
||||
|
|
||||
LL | let _val = (1 as *mut u8).offset(ptr as isize);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -5,6 +5,7 @@ fn main() {
|
||||
unsafe {
|
||||
let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18];
|
||||
let idxs = Simd::from_array([9, 3, 0, 17]);
|
||||
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0)); //~ERROR: pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
||||
//~^ERROR: expected a pointer to 1 byte of memory
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 1 byte of memory, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||
--> $DIR/simd-gather.rs:LL:CC
|
||||
|
|
||||
LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||
|
|
||||
= 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
|
||||
|
@ -6,7 +6,7 @@ fn main() {
|
||||
let mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
|
||||
let idxs = Simd::from_array([9, 3, 0, 17]);
|
||||
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
||||
//~^ERROR: pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
//~^ERROR: expected a pointer to 1 byte of memory
|
||||
&mut vec,
|
||||
Mask::splat(true),
|
||||
idxs,
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 1 byte of memory, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||
--> $DIR/simd-scatter.rs:LL:CC
|
||||
|
|
||||
LL | / Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
||||
@ -7,7 +7,7 @@ LL | | &mut vec,
|
||||
LL | | Mask::splat(true),
|
||||
LL | | idxs,
|
||||
LL | | );
|
||||
| |_________^ memory access failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
||||
| |_________^ memory access failed: expected a pointer to 1 byte of memory, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/pointer_partial_overwrite.rs:LL:CC
|
||||
|
|
||||
LL | let x = *p;
|
||||
| ^^ memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/provenance_transmute.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *left_ptr;
|
||||
| ^^^^^^^^^ memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_int_unexposed.rs:LL:CC
|
||||
|
|
||||
LL | assert_eq!(unsafe { *ptr }, 3);
|
||||
| ^^^^ memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_invalid.rs:LL:CC
|
||||
|
|
||||
LL | let _val = unsafe { *xptr_invalid };
|
||||
| ^^^^^^^^^^^^^ memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/ptr_invalid_offset.rs:LL:CC
|
||||
|
|
||||
LL | let _ = unsafe { roundtrip.offset(1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
--> $DIR/reading_half_a_pointer.rs:LL:CC
|
||||
|
|
||||
LL | let _val = *x;
|
||||
| ^^ memory access failed: $HEX[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^ memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
= 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
|
||||
|
@ -4,6 +4,6 @@ extern "Rust" {
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
miri_resolve_frame(std::ptr::null_mut(), 0); //~ ERROR: null pointer is a dangling pointer
|
||||
miri_resolve_frame(std::ptr::null_mut(), 0); //~ ERROR: got a null pointer
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
--> $DIR/bad-backtrace-ptr.rs:LL:CC
|
||||
|
|
||||
LL | miri_resolve_frame(std::ptr::null_mut(), 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
|
||||
= 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
// make sure ZST locals cannot be accessed
|
||||
let x = &() as *const () as *const i8;
|
||||
let _val = unsafe { *x }; //~ ERROR: out-of-bounds
|
||||
let _val = unsafe { *x }; //~ ERROR: expected a pointer to 1 byte of memory
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: memory access failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
|
||||
error: Undefined Behavior: memory access failed: expected a pointer to 1 byte of memory, but got ALLOC which is at or beyond the end of the allocation of size 0 bytes
|
||||
--> $DIR/zst_local_oob.rs:LL:CC
|
||||
|
|
||||
LL | let _val = unsafe { *x };
|
||||
| ^^ memory access failed: ALLOC has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
|
||||
| ^^ memory access failed: expected a pointer to 1 byte of memory, but got ALLOC which is at or beyond the end of the allocation of size 0 bytes
|
||||
|
|
||||
= 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
|
||||
|
@ -118,7 +118,7 @@ LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC10 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 and there are only 4 bytes starting at that pointer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
@ -177,7 +177,7 @@ LL | pub static R7: &[u16] = unsafe {
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC11 has size 8, so pointer to 8 bytes starting at offset 1 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 and there are only 7 bytes starting at that pointer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
@ -1,7 +1,7 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
|
||||
= note: memory access failed: ALLOC0 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
|
||||
= note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
@ -14,7 +14,7 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
|
||||
= note: memory access failed: ALLOC0 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
|
||||
= note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
@ -29,7 +29,7 @@ LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
|
||||
= note: memory access failed: ALLOC0 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds
|
||||
= note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
@ -2,31 +2,31 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:10:9
|
||||
|
|
||||
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got a null pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:14:9
|
||||
|
|
||||
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:18:9
|
||||
|
|
||||
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:22:9
|
||||
|
|
||||
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 and there are only 3 bytes starting at that pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:26:9
|
||||
|
|
||||
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC1 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 and there are only 3 bytes starting at that pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-compare-bytes-ub.rs:30:9
|
||||
|
@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/const-deref-ptr.rs:4:29
|
||||
|
|
||||
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0xdeadbeef[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_raw_ptr_ops2.rs:7:26
|
||||
|
|
||||
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
|
||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: 0x2a[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_raw_ptr_ops2.rs:9:26
|
||||
|
|
||||
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
|
||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: 0x2c[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/nonnull_as_ref_ub.rs:4:29
|
||||
|
|
||||
LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -440,7 +440,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-bytes.rs:196:62
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-bytes.rs:199:65
|
||||
|
@ -440,7 +440,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-bytes.rs:196:62
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-bytes.rs:199:65
|
||||
|
@ -39,7 +39,7 @@ const OOB: () = unsafe {
|
||||
let mem = [0u32; 1];
|
||||
let ptr = mem.as_ptr().cast::<u64>();
|
||||
let _val = *ptr; //~ERROR: evaluation of constant value failed
|
||||
//~^NOTE: size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
//~^NOTE: expected a pointer to 8 bytes of memory
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
@ -35,7 +35,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:41:16
|
||||
|
|
||||
LL | let _val = *ptr;
|
||||
| ^^^^ memory access failed: ALLOC0 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 and there are only 4 bytes starting at that pointer
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
@ -13,7 +13,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-nonnull.rs:20:29
|
||||
|
|
||||
LL | let out_of_bounds_ptr = &ptr[255];
|
||||
| ^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC1 has size 1, so pointer to 255 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 and there are only 1 bytes starting at that pointer
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-nonnull.rs:24:1
|
||||
|
@ -262,7 +262,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:144:62
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:147:65
|
||||
@ -274,7 +274,7 @@ error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/ub-wide-ptr.rs:156:5
|
||||
|
|
||||
LL | mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: null pointer is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
||||
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/ub-wide-ptr.rs:161:5
|
||||
|
@ -27,7 +27,7 @@ const COPY_OOB_1: () = unsafe {
|
||||
copy_nonoverlapping(0x100 as *const i32, dangle, 0);
|
||||
// Non-zero-sized copy is not.
|
||||
copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR evaluation of constant value failed [E0080]
|
||||
//~| 0x100[noalloc] is a dangling pointer
|
||||
//~| got 0x100[noalloc] which is a dangling pointer
|
||||
};
|
||||
const COPY_OOB_2: () = unsafe {
|
||||
let x = 0i32;
|
||||
@ -36,7 +36,7 @@ const COPY_OOB_2: () = unsafe {
|
||||
copy_nonoverlapping(dangle, 0x100 as *mut i32, 0);
|
||||
// Non-zero-sized copy is not.
|
||||
copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR evaluation of constant value failed [E0080]
|
||||
//~| offset 40 is out-of-bounds
|
||||
//~| +0x28 which is at or beyond the end of the allocation
|
||||
};
|
||||
|
||||
const COPY_SIZE_OVERFLOW: () = unsafe {
|
||||
|
@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:29:5
|
||||
|
|
||||
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x100[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:38:5
|
||||
|
|
||||
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC0 has size 4, so pointer to 4 bytes starting at offset 40 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/copy-intrinsic.rs:45:5
|
||||
|
@ -1,3 +1,4 @@
|
||||
//@ normalize-stderr-test: "to \d+ bytes of memory" -> "to $$BYTES bytes of memory"
|
||||
#![feature(const_ptr_sub_ptr)]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
@ -45,7 +46,7 @@ const OUT_OF_BOUNDS_1: isize = {
|
||||
let end_ptr = (start_ptr).wrapping_add(length);
|
||||
// First ptr is out of bounds
|
||||
unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed
|
||||
//~| pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||
//~| expected a pointer to 10 bytes of memory
|
||||
};
|
||||
|
||||
const OUT_OF_BOUNDS_2: isize = {
|
||||
@ -54,7 +55,7 @@ const OUT_OF_BOUNDS_2: isize = {
|
||||
let end_ptr = (start_ptr).wrapping_add(length);
|
||||
// Second ptr is out of bounds
|
||||
unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed
|
||||
//~| pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||
//~| expected a pointer to 10 bytes of memory
|
||||
};
|
||||
|
||||
pub const DIFFERENT_ALLOC_UNSIGNED: usize = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:18:27
|
||||
--> $DIR/offset_from_ub.rs:19:27
|
||||
|
|
||||
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on pointers into different allocations
|
||||
@ -12,67 +12,67 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `NOT_PTR`
|
||||
--> $DIR/offset_from_ub.rs:24:14
|
||||
--> $DIR/offset_from_ub.rs:25:14
|
||||
|
|
||||
LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:31:14
|
||||
--> $DIR/offset_from_ub.rs:32:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 1_isize cannot be divided by 2_isize without remainder
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:38:14
|
||||
--> $DIR/offset_from_ub.rs:39:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: 0x8[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got 0x8[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:47:14
|
||||
--> $DIR/offset_from_ub.rs:48:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: ALLOC0 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got ALLOC0 and there are only 4 bytes starting at that pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:56:14
|
||||
--> $DIR/offset_from_ub.rs:57:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: ALLOC1 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got ALLOC1 and there are only 4 bytes starting at that pointer
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:65:14
|
||||
--> $DIR/offset_from_ub.rs:66:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:72:14
|
||||
--> $DIR/offset_from_ub.rs:73:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far ahead of second
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:78:14
|
||||
--> $DIR/offset_from_ub.rs:79:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(ptr1, ptr2) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:86:14
|
||||
--> $DIR/offset_from_ub.rs:87:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from(ptr1, ptr2) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:93:14
|
||||
--> $DIR/offset_from_ub.rs:94:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from_unsigned(p, p.add(2) ) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_from_ub.rs:100:14
|
||||
--> $DIR/offset_from_ub.rs:101:14
|
||||
|
|
||||
LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second
|
||||
@ -80,12 +80,12 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) }
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance)
|
||||
= note: out-of-bounds `offset_from`: expected a pointer to $BYTES bytes of memory, but got a null pointer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `OFFSET_VERY_FAR1`
|
||||
--> $DIR/offset_from_ub.rs:109:14
|
||||
--> $DIR/offset_from_ub.rs:110:14
|
||||
|
|
||||
LL | unsafe { ptr2.offset_from(ptr1) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -98,7 +98,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `OFFSET_VERY_FAR2`
|
||||
--> $DIR/offset_from_ub.rs:115:14
|
||||
--> $DIR/offset_from_ub.rs:116:14
|
||||
|
|
||||
LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,6 +2,7 @@ use std::ptr;
|
||||
|
||||
//@ normalize-stderr-test: "0xf+" -> "0xf..f"
|
||||
//@ normalize-stderr-test: "0x7f+" -> "0x7f..f"
|
||||
//@ normalize-stderr-test: "to \d+ bytes of memory" -> "to $$BYTES bytes of memory"
|
||||
|
||||
|
||||
pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; //~NOTE
|
||||
|
@ -6,7 +6,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `BEFORE_START`
|
||||
--> $DIR/offset_ub.rs:7:46
|
||||
--> $DIR/offset_ub.rs:8:46
|
||||
|
|
||||
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -14,12 +14,12 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1)
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC0 has size 1, so pointer to 2 bytes starting at offset 0 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC0 and there are only 1 bytes starting at that pointer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `AFTER_END`
|
||||
--> $DIR/offset_ub.rs:8:43
|
||||
--> $DIR/offset_ub.rs:9:43
|
||||
|
|
||||
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -27,12 +27,12 @@ LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC1 has size 100, so pointer to 101 bytes starting at offset 0 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 and there are only 100 bytes starting at that pointer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `AFTER_ARRAY`
|
||||
--> $DIR/offset_ub.rs:9:45
|
||||
--> $DIR/offset_ub.rs:10:45
|
||||
|
|
||||
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -45,7 +45,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `OVERFLOW`
|
||||
--> $DIR/offset_ub.rs:11:43
|
||||
--> $DIR/offset_ub.rs:12:43
|
||||
|
|
||||
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -58,7 +58,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `UNDERFLOW`
|
||||
--> $DIR/offset_ub.rs:12:44
|
||||
--> $DIR/offset_ub.rs:13:44
|
||||
|
|
||||
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -71,7 +71,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `OVERFLOW_ADDRESS_SPACE`
|
||||
--> $DIR/offset_ub.rs:13:56
|
||||
--> $DIR/offset_ub.rs:14:56
|
||||
|
|
||||
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -84,7 +84,7 @@ error[E0080]: evaluation of constant value failed
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `UNDERFLOW_ADDRESS_SPACE`
|
||||
--> $DIR/offset_ub.rs:14:57
|
||||
--> $DIR/offset_ub.rs:15:57
|
||||
|
|
||||
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -92,12 +92,12 @@ LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).of
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC2 has size 1, so pointer to 2 bytes starting at offset -4 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2-0x4 which points to before the beginning of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `NEGATIVE_OFFSET`
|
||||
--> $DIR/offset_ub.rs:15:49
|
||||
--> $DIR/offset_ub.rs:16:49
|
||||
|
|
||||
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -105,12 +105,12 @@ LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: ALLOC3 has size 0, so pointer to 1 byte starting at offset 0 is out-of-bounds
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC3 which is at or beyond the end of the allocation of size 0 bytes
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `ZERO_SIZED_ALLOC`
|
||||
--> $DIR/offset_ub.rs:17:50
|
||||
--> $DIR/offset_ub.rs:18:50
|
||||
|
|
||||
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -118,12 +118,12 @@ LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||
note: inside `DANGLING`
|
||||
--> $DIR/offset_ub.rs:18:42
|
||||
--> $DIR/offset_ub.rs:19:42
|
||||
|
|
||||
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -131,12 +131,12 @@ LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
|
||||
= note: out-of-bounds pointer arithmetic: 0x7f..f[noalloc] is a dangling pointer (it has no provenance)
|
||||
= note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x7f..f[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `UNDERFLOW_ABS`
|
||||
--> $DIR/offset_ub.rs:21:47
|
||||
--> $DIR/offset_ub.rs:22:47
|
||||
|
|
||||
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/E0396-fixed.rs:5:28
|
||||
|
|
||||
LL | const VALUE: u8 = unsafe { *REG_ADDR };
|
||||
| ^^^^^^^^^ memory access failed: 0x5f3759df[noalloc] is a dangling pointer (it has no provenance)
|
||||
| ^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x5f3759df[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user