interpret: better error message for out-of-bounds pointer arithmetic and accesses
This commit is contained in:
@@ -12,6 +12,27 @@ const_eval_already_reported =
|
|||||||
const_eval_assume_false =
|
const_eval_assume_false =
|
||||||
`assume` called with `false`
|
`assume` called with `false`
|
||||||
|
|
||||||
|
const_eval_bad_pointer_op = {$operation ->
|
||||||
|
[MemoryAccess] memory access failed
|
||||||
|
[InboundsPointerArithmetic] in-bounds pointer arithmetic failed
|
||||||
|
*[Dereferenceable] pointer not dereferenceable
|
||||||
|
}
|
||||||
|
const_eval_bad_pointer_op_attempting = {const_eval_bad_pointer_op}: {$operation ->
|
||||||
|
[MemoryAccess] attempting to access {$inbounds_size ->
|
||||||
|
[1] 1 byte
|
||||||
|
*[x] {$inbounds_size} bytes
|
||||||
|
}
|
||||||
|
[InboundsPointerArithmetic] attempting to offset pointer by {$inbounds_size ->
|
||||||
|
[1] 1 byte
|
||||||
|
*[x] {$inbounds_size} bytes
|
||||||
|
}
|
||||||
|
*[Dereferenceable] pointer must {$inbounds_size ->
|
||||||
|
[0] point to some allocation
|
||||||
|
[1] be dereferenceable for 1 byte
|
||||||
|
*[x] be dereferenceable for {$inbounds_size} bytes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const_eval_bounds_check_failed =
|
const_eval_bounds_check_failed =
|
||||||
indexing out of bounds: the len is {$len} but the index is {$index}
|
indexing out of bounds: the len is {$len} but the index is {$index}
|
||||||
const_eval_call_nonzero_intrinsic =
|
const_eval_call_nonzero_intrinsic =
|
||||||
@@ -39,9 +60,9 @@ const_eval_copy_nonoverlapping_overlapping =
|
|||||||
`copy_nonoverlapping` called on overlapping ranges
|
`copy_nonoverlapping` called on overlapping ranges
|
||||||
|
|
||||||
const_eval_dangling_int_pointer =
|
const_eval_dangling_int_pointer =
|
||||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got {$pointer} which is a dangling pointer (it has no provenance)
|
{const_eval_bad_pointer_op_attempting}, but got {$pointer} which is a dangling pointer (it has no provenance)
|
||||||
const_eval_dangling_null_pointer =
|
const_eval_dangling_null_pointer =
|
||||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got a null pointer
|
{const_eval_bad_pointer_op_attempting}, but got null pointer
|
||||||
|
|
||||||
const_eval_dangling_ptr_in_final = encountered dangling pointer in final value of {const_eval_intern_kind}
|
const_eval_dangling_ptr_in_final = encountered dangling pointer in final value of {const_eval_intern_kind}
|
||||||
const_eval_dead_local =
|
const_eval_dead_local =
|
||||||
@@ -77,21 +98,6 @@ const_eval_error = {$error_kind ->
|
|||||||
const_eval_exact_div_has_remainder =
|
const_eval_exact_div_has_remainder =
|
||||||
exact_div: {$a} cannot be divided by {$b} without remainder
|
exact_div: {$a} cannot be divided by {$b} without remainder
|
||||||
|
|
||||||
const_eval_expected_inbounds_pointer =
|
|
||||||
expected a pointer to {$inbounds_size_abs ->
|
|
||||||
[0] some allocation
|
|
||||||
*[x] {$inbounds_size_is_neg ->
|
|
||||||
[false] {$inbounds_size_abs ->
|
|
||||||
[1] 1 byte of memory
|
|
||||||
*[x] {$inbounds_size_abs} bytes of memory
|
|
||||||
}
|
|
||||||
*[true] the end of {$inbounds_size_abs ->
|
|
||||||
[1] 1 byte of memory
|
|
||||||
*[x] {$inbounds_size_abs} bytes of memory
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const_eval_extern_static =
|
const_eval_extern_static =
|
||||||
cannot access extern static `{$did}`
|
cannot access extern static `{$did}`
|
||||||
const_eval_extern_type_field = `extern type` field does not have a known offset
|
const_eval_extern_type_field = `extern type` field does not have a known offset
|
||||||
@@ -111,7 +117,6 @@ const_eval_frame_note_inner = inside {$where_ ->
|
|||||||
|
|
||||||
const_eval_frame_note_last = the failure occurred here
|
const_eval_frame_note_last = the failure occurred here
|
||||||
|
|
||||||
const_eval_in_bounds_test = out-of-bounds pointer use
|
|
||||||
const_eval_incompatible_calling_conventions =
|
const_eval_incompatible_calling_conventions =
|
||||||
calling a function with calling convention {$callee_conv} using calling convention {$caller_conv}
|
calling a function with calling convention {$callee_conv} using calling convention {$caller_conv}
|
||||||
|
|
||||||
@@ -206,7 +211,6 @@ const_eval_long_running =
|
|||||||
|
|
||||||
const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id}
|
const_eval_max_num_nodes_in_const = maximum number of nodes exceeded in constant {$global_const_id}
|
||||||
|
|
||||||
const_eval_memory_access_test = memory access failed
|
|
||||||
const_eval_memory_exhausted =
|
const_eval_memory_exhausted =
|
||||||
tried to allocate more memory than available to compiler
|
tried to allocate more memory than available to compiler
|
||||||
|
|
||||||
@@ -287,8 +291,6 @@ const_eval_offset_from_out_of_bounds =
|
|||||||
`{$name}` called on two different pointers where the memory range between them is not in-bounds of an allocation
|
`{$name}` called on two different pointers where the memory range between them is not in-bounds of an allocation
|
||||||
const_eval_offset_from_overflow =
|
const_eval_offset_from_overflow =
|
||||||
`{$name}` called when first pointer is too far ahead of second
|
`{$name}` called when first pointer is too far ahead of second
|
||||||
const_eval_offset_from_test =
|
|
||||||
out-of-bounds `offset_from` origin
|
|
||||||
const_eval_offset_from_underflow =
|
const_eval_offset_from_underflow =
|
||||||
`{$name}` called when first pointer is too far before second
|
`{$name}` called when first pointer is too far before second
|
||||||
const_eval_offset_from_unsigned_overflow =
|
const_eval_offset_from_unsigned_overflow =
|
||||||
@@ -312,27 +314,25 @@ const_eval_partial_pointer_overwrite =
|
|||||||
unable to overwrite parts of a pointer in memory at {$ptr}
|
unable to overwrite parts of a pointer in memory at {$ptr}
|
||||||
const_eval_pointer_arithmetic_overflow =
|
const_eval_pointer_arithmetic_overflow =
|
||||||
overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
|
overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
|
||||||
const_eval_pointer_arithmetic_test = out-of-bounds pointer arithmetic
|
|
||||||
const_eval_pointer_out_of_bounds =
|
const_eval_pointer_out_of_bounds =
|
||||||
{$bad_pointer_message}: {const_eval_expected_inbounds_pointer}, but got {$pointer} {$ptr_offset_is_neg ->
|
{const_eval_bad_pointer_op_attempting}, but got {$pointer} which {$inbounds_size_is_neg ->
|
||||||
[true] which points to before the beginning of the allocation
|
[false] {$alloc_size_minus_ptr_offset ->
|
||||||
*[false] {$inbounds_size_is_neg ->
|
[0] is at or beyond the end of the allocation of size {$alloc_size ->
|
||||||
[true] {$ptr_offset_abs ->
|
|
||||||
[0] which is at the beginning of the allocation
|
|
||||||
*[other] which does not have enough space to 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
|
[1] 1 byte
|
||||||
*[x] {$alloc_size} bytes
|
*[x] {$alloc_size} bytes
|
||||||
}
|
}
|
||||||
[1] which is only 1 byte from the end of the allocation
|
[1] is only 1 byte from the end of the allocation
|
||||||
*[x] which is only {$alloc_size_minus_ptr_offset} bytes from the end of the allocation
|
*[x] is only {$alloc_size_minus_ptr_offset} bytes from the end of the allocation
|
||||||
|
}
|
||||||
|
*[true] {$ptr_offset_abs ->
|
||||||
|
[0] is at the beginning of the allocation
|
||||||
|
*[other] is only {$ptr_offset_abs} bytes from the beginning of the allocation
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_eval_pointer_use_after_free =
|
const_eval_pointer_use_after_free =
|
||||||
{$bad_pointer_message}: {$alloc_id} has been freed, so this pointer is dangling
|
{const_eval_bad_pointer_op}: {$alloc_id} has been freed, so this pointer is dangling
|
||||||
const_eval_ptr_as_bytes_1 =
|
const_eval_ptr_as_bytes_1 =
|
||||||
this code performed an operation that depends on the underlying bytes representing a pointer
|
this code performed an operation that depends on the underlying bytes representing a pointer
|
||||||
const_eval_ptr_as_bytes_2 =
|
const_eval_ptr_as_bytes_2 =
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ use either::Either;
|
|||||||
use rustc_abi::WrappingRange;
|
use rustc_abi::WrappingRange;
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level,
|
Diag, DiagArgValue, DiagMessage, Diagnostic, EmissionGuarantee, Level, MultiSpan, Subdiagnostic,
|
||||||
MultiSpan, Subdiagnostic,
|
|
||||||
};
|
};
|
||||||
use rustc_hir::ConstContext;
|
use rustc_hir::ConstContext;
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
|
||||||
use rustc_middle::mir::interpret::{
|
use rustc_middle::mir::interpret::{
|
||||||
CheckInAllocMsg, CtfeProvenance, ExpectedKind, InterpErrorKind, InvalidMetaKind,
|
CtfeProvenance, ExpectedKind, InterpErrorKind, InvalidMetaKind, InvalidProgramInfo,
|
||||||
InvalidProgramInfo, Misalignment, Pointer, PointerKind, ResourceExhaustionInfo,
|
Misalignment, Pointer, PointerKind, ResourceExhaustionInfo, UndefinedBehaviorInfo,
|
||||||
UndefinedBehaviorInfo, UnsupportedOpInfo, ValidationErrorInfo,
|
UnsupportedOpInfo, ValidationErrorInfo,
|
||||||
};
|
};
|
||||||
use rustc_middle::ty::{self, Mutability, Ty};
|
use rustc_middle::ty::{self, Mutability, Ty};
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
@@ -498,19 +497,6 @@ pub trait ReportErrorExt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bad_pointer_message(msg: CheckInAllocMsg, dcx: DiagCtxtHandle<'_>) -> String {
|
|
||||||
use crate::fluent_generated::*;
|
|
||||||
|
|
||||||
let msg = match msg {
|
|
||||||
CheckInAllocMsg::MemoryAccessTest => const_eval_memory_access_test,
|
|
||||||
CheckInAllocMsg::PointerArithmeticTest => const_eval_pointer_arithmetic_test,
|
|
||||||
CheckInAllocMsg::OffsetFromTest => const_eval_offset_from_test,
|
|
||||||
CheckInAllocMsg::InboundsTest => const_eval_in_bounds_test,
|
|
||||||
};
|
|
||||||
|
|
||||||
dcx.eagerly_translate_to_string(msg, [].into_iter())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
||||||
fn diagnostic_message(&self) -> DiagMessage {
|
fn diagnostic_message(&self) -> DiagMessage {
|
||||||
use UndefinedBehaviorInfo::*;
|
use UndefinedBehaviorInfo::*;
|
||||||
@@ -564,7 +550,6 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
|||||||
|
|
||||||
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||||
use UndefinedBehaviorInfo::*;
|
use UndefinedBehaviorInfo::*;
|
||||||
let dcx = diag.dcx;
|
|
||||||
match self {
|
match self {
|
||||||
Ub(_) => {}
|
Ub(_) => {}
|
||||||
Custom(custom) => {
|
Custom(custom) => {
|
||||||
@@ -612,12 +597,10 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
|||||||
diag.arg("vtable_dyn_type", vtable_dyn_type.to_string());
|
diag.arg("vtable_dyn_type", vtable_dyn_type.to_string());
|
||||||
}
|
}
|
||||||
PointerUseAfterFree(alloc_id, msg) => {
|
PointerUseAfterFree(alloc_id, msg) => {
|
||||||
diag.arg("alloc_id", alloc_id)
|
diag.arg("alloc_id", alloc_id).arg("operation", format!("{:?}", msg));
|
||||||
.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
|
||||||
}
|
}
|
||||||
PointerOutOfBounds { alloc_id, alloc_size, ptr_offset, inbounds_size, msg } => {
|
PointerOutOfBounds { alloc_id, alloc_size, ptr_offset, inbounds_size, msg } => {
|
||||||
diag.arg("alloc_size", alloc_size.bytes());
|
diag.arg("alloc_size", alloc_size.bytes());
|
||||||
diag.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
|
||||||
diag.arg("pointer", {
|
diag.arg("pointer", {
|
||||||
let mut out = format!("{:?}", alloc_id);
|
let mut out = format!("{:?}", alloc_id);
|
||||||
if ptr_offset > 0 {
|
if ptr_offset > 0 {
|
||||||
@@ -627,14 +610,17 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
|||||||
}
|
}
|
||||||
out
|
out
|
||||||
});
|
});
|
||||||
|
diag.arg("inbounds_size", inbounds_size);
|
||||||
diag.arg("inbounds_size_is_neg", inbounds_size < 0);
|
diag.arg("inbounds_size_is_neg", inbounds_size < 0);
|
||||||
diag.arg("inbounds_size_abs", inbounds_size.unsigned_abs());
|
diag.arg("inbounds_size_abs", inbounds_size.unsigned_abs());
|
||||||
|
diag.arg("ptr_offset", ptr_offset);
|
||||||
diag.arg("ptr_offset_is_neg", ptr_offset < 0);
|
diag.arg("ptr_offset_is_neg", ptr_offset < 0);
|
||||||
diag.arg("ptr_offset_abs", ptr_offset.unsigned_abs());
|
diag.arg("ptr_offset_abs", ptr_offset.unsigned_abs());
|
||||||
diag.arg(
|
diag.arg(
|
||||||
"alloc_size_minus_ptr_offset",
|
"alloc_size_minus_ptr_offset",
|
||||||
alloc_size.bytes().saturating_sub(ptr_offset as u64),
|
alloc_size.bytes().saturating_sub(ptr_offset as u64),
|
||||||
);
|
);
|
||||||
|
diag.arg("operation", format!("{:?}", msg));
|
||||||
}
|
}
|
||||||
DanglingIntPointer { addr, inbounds_size, msg } => {
|
DanglingIntPointer { addr, inbounds_size, msg } => {
|
||||||
if addr != 0 {
|
if addr != 0 {
|
||||||
@@ -644,9 +630,10 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diag.arg("inbounds_size", inbounds_size);
|
||||||
diag.arg("inbounds_size_is_neg", inbounds_size < 0);
|
diag.arg("inbounds_size_is_neg", inbounds_size < 0);
|
||||||
diag.arg("inbounds_size_abs", inbounds_size.unsigned_abs());
|
diag.arg("inbounds_size_abs", inbounds_size.unsigned_abs());
|
||||||
diag.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
|
diag.arg("operation", format!("{:?}", msg));
|
||||||
}
|
}
|
||||||
AlignmentCheckFailed(Misalignment { required, has }, msg) => {
|
AlignmentCheckFailed(Misalignment { required, has }, msg) => {
|
||||||
diag.arg("required", required.bytes());
|
diag.arg("required", required.bytes());
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
|
|
||||||
// Check that the memory between them is dereferenceable at all, starting from the
|
// Check that the memory between them is dereferenceable at all, starting from the
|
||||||
// origin pointer: `dist` is `a - b`, so it is based on `b`.
|
// origin pointer: `dist` is `a - b`, so it is based on `b`.
|
||||||
self.check_ptr_access_signed(b, dist, CheckInAllocMsg::OffsetFromTest)
|
self.check_ptr_access_signed(b, dist, CheckInAllocMsg::Dereferenceable)
|
||||||
.map_err_kind(|_| {
|
.map_err_kind(|_| {
|
||||||
// This could mean they point to different allocations, or they point to the same allocation
|
// This could mean they point to different allocations, or they point to the same allocation
|
||||||
// but not the entire range between the pointers is in-bounds.
|
// but not the entire range between the pointers is in-bounds.
|
||||||
@@ -373,7 +373,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
self.check_ptr_access_signed(
|
self.check_ptr_access_signed(
|
||||||
a,
|
a,
|
||||||
dist.checked_neg().unwrap(), // i64::MIN is impossible as no allocation can be that large
|
dist.checked_neg().unwrap(), // i64::MIN is impossible as no allocation can be that large
|
||||||
CheckInAllocMsg::OffsetFromTest,
|
CheckInAllocMsg::Dereferenceable,
|
||||||
)
|
)
|
||||||
.map_err_kind(|_| {
|
.map_err_kind(|_| {
|
||||||
// Make the error more specific.
|
// Make the error more specific.
|
||||||
@@ -652,7 +652,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
offset_bytes: i64,
|
offset_bytes: i64,
|
||||||
) -> InterpResult<'tcx, Pointer<Option<M::Provenance>>> {
|
) -> InterpResult<'tcx, Pointer<Option<M::Provenance>>> {
|
||||||
// The offset must be in bounds starting from `ptr`.
|
// The offset must be in bounds starting from `ptr`.
|
||||||
self.check_ptr_access_signed(ptr, offset_bytes, CheckInAllocMsg::PointerArithmeticTest)?;
|
self.check_ptr_access_signed(
|
||||||
|
ptr,
|
||||||
|
offset_bytes,
|
||||||
|
CheckInAllocMsg::InboundsPointerArithmetic,
|
||||||
|
)?;
|
||||||
// This also implies that there is no overflow, so we are done.
|
// This also implies that there is no overflow, so we are done.
|
||||||
interp_ok(ptr.wrapping_signed_offset(offset_bytes, self))
|
interp_ok(ptr.wrapping_signed_offset(offset_bytes, self))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
kind = "static_mem"
|
kind = "static_mem"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
None => err_ub!(PointerUseAfterFree(alloc_id, CheckInAllocMsg::MemoryAccessTest)),
|
None => err_ub!(PointerUseAfterFree(alloc_id, CheckInAllocMsg::MemoryAccess)),
|
||||||
})
|
})
|
||||||
.into();
|
.into();
|
||||||
};
|
};
|
||||||
@@ -414,10 +414,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
self,
|
self,
|
||||||
ptr,
|
ptr,
|
||||||
size,
|
size,
|
||||||
CheckInAllocMsg::MemoryAccessTest,
|
CheckInAllocMsg::MemoryAccess,
|
||||||
|this, alloc_id, offset, prov| {
|
|this, alloc_id, offset, prov| {
|
||||||
let (size, align) = this
|
let (size, align) =
|
||||||
.get_live_alloc_size_and_align(alloc_id, CheckInAllocMsg::MemoryAccessTest)?;
|
this.get_live_alloc_size_and_align(alloc_id, CheckInAllocMsg::MemoryAccess)?;
|
||||||
interp_ok((size, align, (alloc_id, offset, prov)))
|
interp_ok((size, align, (alloc_id, offset, prov)))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -613,7 +613,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
}
|
}
|
||||||
Some(GlobalAlloc::Function { .. }) => throw_ub!(DerefFunctionPointer(id)),
|
Some(GlobalAlloc::Function { .. }) => throw_ub!(DerefFunctionPointer(id)),
|
||||||
Some(GlobalAlloc::VTable(..)) => throw_ub!(DerefVTablePointer(id)),
|
Some(GlobalAlloc::VTable(..)) => throw_ub!(DerefVTablePointer(id)),
|
||||||
None => throw_ub!(PointerUseAfterFree(id, CheckInAllocMsg::MemoryAccessTest)),
|
None => throw_ub!(PointerUseAfterFree(id, CheckInAllocMsg::MemoryAccess)),
|
||||||
Some(GlobalAlloc::Static(def_id)) => {
|
Some(GlobalAlloc::Static(def_id)) => {
|
||||||
assert!(self.tcx.is_static(def_id));
|
assert!(self.tcx.is_static(def_id));
|
||||||
// Thread-local statics do not have a constant address. They *must* be accessed via
|
// Thread-local statics do not have a constant address. They *must* be accessed via
|
||||||
@@ -707,7 +707,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
self,
|
self,
|
||||||
ptr,
|
ptr,
|
||||||
size_i64,
|
size_i64,
|
||||||
CheckInAllocMsg::MemoryAccessTest,
|
CheckInAllocMsg::MemoryAccess,
|
||||||
|this, alloc_id, offset, prov| {
|
|this, alloc_id, offset, prov| {
|
||||||
let alloc = this.get_alloc_raw(alloc_id)?;
|
let alloc = this.get_alloc_raw(alloc_id)?;
|
||||||
interp_ok((alloc.size(), alloc.align, (alloc_id, offset, prov, alloc)))
|
interp_ok((alloc.size(), alloc.align, (alloc_id, offset, prov, alloc)))
|
||||||
@@ -809,7 +809,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
self,
|
self,
|
||||||
ptr,
|
ptr,
|
||||||
size_i64,
|
size_i64,
|
||||||
CheckInAllocMsg::MemoryAccessTest,
|
CheckInAllocMsg::MemoryAccess,
|
||||||
|this, alloc_id, offset, prov| {
|
|this, alloc_id, offset, prov| {
|
||||||
let (alloc, machine) = this.get_alloc_raw_mut(alloc_id)?;
|
let (alloc, machine) = this.get_alloc_raw_mut(alloc_id)?;
|
||||||
interp_ok((alloc.size(), alloc.align, (alloc_id, offset, prov, alloc, machine)))
|
interp_ok((alloc.size(), alloc.align, (alloc_id, offset, prov, alloc, machine)))
|
||||||
@@ -1615,7 +1615,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||||||
err_ub!(DanglingIntPointer {
|
err_ub!(DanglingIntPointer {
|
||||||
addr: offset,
|
addr: offset,
|
||||||
inbounds_size: size,
|
inbounds_size: size,
|
||||||
msg: CheckInAllocMsg::InboundsTest
|
msg: CheckInAllocMsg::Dereferenceable
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
|
|||||||
@@ -510,7 +510,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
|
|||||||
self.ecx.check_ptr_access(
|
self.ecx.check_ptr_access(
|
||||||
place.ptr(),
|
place.ptr(),
|
||||||
size,
|
size,
|
||||||
CheckInAllocMsg::InboundsTest, // will anyway be replaced by validity message
|
CheckInAllocMsg::Dereferenceable, // will anyway be replaced by validity message
|
||||||
),
|
),
|
||||||
self.path,
|
self.path,
|
||||||
Ub(DanglingIntPointer { addr: 0, .. }) => NullPtr { ptr_kind },
|
Ub(DanglingIntPointer { addr: 0, .. }) => NullPtr { ptr_kind },
|
||||||
|
|||||||
@@ -221,13 +221,11 @@ pub enum InvalidProgramInfo<'tcx> {
|
|||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum CheckInAllocMsg {
|
pub enum CheckInAllocMsg {
|
||||||
/// We are access memory.
|
/// We are access memory.
|
||||||
MemoryAccessTest,
|
MemoryAccess,
|
||||||
/// We are doing pointer arithmetic.
|
/// We are doing pointer arithmetic.
|
||||||
PointerArithmeticTest,
|
InboundsPointerArithmetic,
|
||||||
/// We are doing pointer offset_from.
|
|
||||||
OffsetFromTest,
|
|
||||||
/// None of the above -- generic/unspecific inbounds test.
|
/// None of the above -- generic/unspecific inbounds test.
|
||||||
InboundsTest,
|
Dereferenceable,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Details of which pointer is not aligned.
|
/// Details of which pointer is not aligned.
|
||||||
|
|||||||
@@ -594,7 +594,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
) -> InterpResult<'tcx, Option<Provenance>> {
|
) -> InterpResult<'tcx, Option<Provenance>> {
|
||||||
let this = self.eval_context_mut();
|
let this = self.eval_context_mut();
|
||||||
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
|
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
|
||||||
this.check_ptr_access(place.ptr(), size, CheckInAllocMsg::InboundsTest)?;
|
this.check_ptr_access(place.ptr(), size, CheckInAllocMsg::Dereferenceable)?;
|
||||||
|
|
||||||
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
|
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
|
||||||
let log_creation = |this: &MiriInterpCx<'tcx>,
|
let log_creation = |this: &MiriInterpCx<'tcx>,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
// Make sure the new permission makes sense as the initial permission of a fresh tag.
|
// Make sure the new permission makes sense as the initial permission of a fresh tag.
|
||||||
assert!(new_perm.initial_state.is_initial());
|
assert!(new_perm.initial_state.is_initial());
|
||||||
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
|
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
|
||||||
this.check_ptr_access(place.ptr(), ptr_size, CheckInAllocMsg::InboundsTest)?;
|
this.check_ptr_access(place.ptr(), ptr_size, CheckInAllocMsg::Dereferenceable)?;
|
||||||
|
|
||||||
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
|
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
|
||||||
let log_creation = |this: &MiriInterpCx<'tcx>,
|
let log_creation = |this: &MiriInterpCx<'tcx>,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub fn prctl<'tcx>(
|
|||||||
ecx.check_ptr_access(
|
ecx.check_ptr_access(
|
||||||
name.to_pointer(ecx)?,
|
name.to_pointer(ecx)?,
|
||||||
Size::from_bytes(TASK_COMM_LEN),
|
Size::from_bytes(TASK_COMM_LEN),
|
||||||
CheckInAllocMsg::MemoryAccessTest,
|
CheckInAllocMsg::MemoryAccess,
|
||||||
)?;
|
)?;
|
||||||
let res = ecx.pthread_getname_np(thread, name, len, /* truncate*/ false)?;
|
let res = ecx.pthread_getname_np(thread, name, len, /* truncate*/ false)?;
|
||||||
assert_eq!(res, ThreadNameResult::Ok);
|
assert_eq!(res, ThreadNameResult::Ok);
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
trace!("Reading from FD {}, size {}", fd_num, count);
|
trace!("Reading from FD {}, size {}", fd_num, count);
|
||||||
|
|
||||||
// Check that the *entire* buffer is actually valid memory.
|
// Check that the *entire* buffer is actually valid memory.
|
||||||
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
|
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccess)?;
|
||||||
|
|
||||||
// We cap the number of read bytes to the largest value that we are able to fit in both the
|
// We cap the number of read bytes to the largest value that we are able to fit in both the
|
||||||
// host's and target's `isize`. This saves us from having to handle overflows later.
|
// host's and target's `isize`. This saves us from having to handle overflows later.
|
||||||
@@ -292,7 +292,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||||||
// Isolation check is done via `FileDescription` trait.
|
// Isolation check is done via `FileDescription` trait.
|
||||||
|
|
||||||
// Check that the *entire* buffer is actually valid memory.
|
// Check that the *entire* buffer is actually valid memory.
|
||||||
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
|
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccess)?;
|
||||||
|
|
||||||
// We cap the number of written bytes to the largest value that we are able to fit in both the
|
// We cap the number of written bytes to the largest value that we are able to fit in both the
|
||||||
// host's and target's `isize`. This saves us from having to handle overflows later.
|
// host's and target's `isize`. This saves us from having to handle overflows later.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: memory access failed: expected a pointer to 129 bytes of memory, but got ALLOC which is only 128 bytes from the end of the allocation
|
error: Undefined Behavior: memory access failed: attempting to access 129 bytes, but got ALLOC which is only 128 bytes from the end of the allocation
|
||||||
--> tests/fail-dep/libc/affinity.rs:LL:CC
|
--> tests/fail-dep/libc/affinity.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let err = unsafe { sched_setaffinity(PID, size_of::<cpu_set_t>() + 1, &cpuset) };
|
LL | let err = unsafe { sched_setaffinity(PID, size_of::<cpu_set_t>() + 1, &cpuset) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 129 bytes of memory, but got ALLOC which is only 128 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 129 bytes, but got ALLOC which is only 128 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to some allocation, but got a null pointer
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
--> tests/fail-dep/libc/memchr_null.rs:LL:CC
|
--> tests/fail-dep/libc/memchr_null.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | libc::memchr(ptr::null(), 0, 0);
|
LL | libc::memchr(ptr::null(), 0, 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to some allocation, but got a null pointer
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
--> tests/fail-dep/libc/memcmp_null.rs:LL:CC
|
--> tests/fail-dep/libc/memcmp_null.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | libc::memcmp(ptr::null(), ptr::null(), 0);
|
LL | libc::memcmp(ptr::null(), ptr::null(), 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail-dep/libc/memcmp_zero.rs:LL:CC
|
--> tests/fail-dep/libc/memcmp_zero.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | libc::memcmp(ptr.cast(), ptr.cast(), 0);
|
LL | libc::memcmp(ptr.cast(), ptr.cast(), 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point 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: 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
|
= 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: expected a pointer to some allocation, but got 0x17[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got 0x17[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail-dep/libc/memcpy_zero.rs:LL:CC
|
--> tests/fail-dep/libc/memcpy_zero.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | libc::memcpy(to.cast(), from.cast(), 0);
|
LL | libc::memcpy(to.cast(), from.cast(), 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x17[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point 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: 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
|
= 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: expected a pointer to some allocation, but got a null pointer
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
--> tests/fail-dep/libc/memrchr_null.rs:LL:CC
|
--> tests/fail-dep/libc/memrchr_null.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | libc::memrchr(ptr::null(), 0, 0);
|
LL | libc::memrchr(ptr::null(), 0, 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//@revisions: stack tree
|
//@revisions: stack tree
|
||||||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||||
//@error-in-other-file: expected a pointer to 4 bytes of memory
|
//@error-in-other-file: pointer not dereferenceable
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC which is only 2 bytes from the end of the allocation
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got ALLOC which is only 2 bytes from the end of the allocation
|
||||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC which is only 2 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got ALLOC which is only 2 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to 4 bytes of memory, but got ALLOC which is only 2 bytes from the end of the allocation
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got ALLOC which is only 2 bytes from the end of the allocation
|
||||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to 4 bytes of memory, but got ALLOC which is only 2 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got ALLOC which is only 2 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got 0x4[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
--> RUSTLIB/alloc/src/boxed.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
LL | Box(unsafe { Unique::new_unchecked(raw) }, alloc)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, 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: 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ fn main() {
|
|||||||
let b = Box::new(42);
|
let b = Box::new(42);
|
||||||
&*b as *const i32
|
&*b as *const i32
|
||||||
};
|
};
|
||||||
let x = unsafe { p.offset(42) }; //~ ERROR: /out-of-bounds pointer arithmetic: .* has been freed/
|
let x = unsafe { p.offset(42) }; //~ ERROR: /in-bounds pointer arithmetic failed: .* has been freed/
|
||||||
panic!("this should never print: {:?}", x);
|
panic!("this should never print: {:?}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
--> tests/fail/dangling_pointers/dangling_pointer_offset.rs:LL:CC
|
--> tests/fail/dangling_pointers/dangling_pointer_offset.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { p.offset(42) };
|
LL | let x = unsafe { p.offset(42) };
|
||||||
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
| ^^^^^^^^^^^^ in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ fn main() {
|
|||||||
&*b as *const i32 as *const (u8, u8, u8, u8)
|
&*b as *const i32 as *const (u8, u8, u8, u8)
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
let _ = (*p).1; //~ ERROR: out-of-bounds pointer arithmetic
|
let _ = (*p).1; //~ ERROR: in-bounds pointer arithmetic failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_let.rs:LL:CC
|
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_let.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _ = (*p).1;
|
LL | let _ = (*p).1;
|
||||||
| ^^^^^^ out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
| ^^^^^^ in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ fn main() {
|
|||||||
&*b as *const i32 as *const (u8, u8, u8, u8)
|
&*b as *const i32 as *const (u8, u8, u8, u8)
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
let _: u8 = (*p).1; //~ ERROR: out-of-bounds pointer arithmetic
|
let _: u8 = (*p).1; //~ ERROR: in-bounds pointer arithmetic failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_let_type_annotation.rs:LL:CC
|
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_let_type_annotation.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _: u8 = (*p).1;
|
LL | let _: u8 = (*p).1;
|
||||||
| ^^^^^^ out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
| ^^^^^^ in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
match (*p).1 {
|
match (*p).1 {
|
||||||
//~^ ERROR: out-of-bounds pointer arithmetic
|
//~^ ERROR: in-bounds pointer arithmetic failed
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_match.rs:LL:CC
|
--> tests/fail/dangling_pointers/dangling_pointer_project_underscore_match.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | match (*p).1 {
|
LL | match (*p).1 {
|
||||||
| ^^^^^^ out-of-bounds pointer arithmetic: ALLOC has been freed, so this pointer is dangling
|
| ^^^^^^ in-bounds pointer arithmetic failed: ALLOC has been freed, so this pointer is dangling
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs:LL:CC
|
--> tests/fail/dangling_pointers/dangling_pointer_to_raw_pointer.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | unsafe { &(*x).0 as *const i32 }
|
LL | unsafe { &(*x).0 as *const i32 }
|
||||||
| ^^^^^^^ 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)
|
| ^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got 0x10[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/dangling_pointers/deref-invalid-ptr.rs:LL:CC
|
--> tests/fail/dangling_pointers/deref-invalid-ptr.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _y = unsafe { &*x as *const u32 };
|
LL | let _y = unsafe { &*x as *const u32 };
|
||||||
| ^^^ 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)
|
| ^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got a null pointer
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got null pointer
|
||||||
--> tests/fail/dangling_pointers/null_pointer_deref.rs:LL:CC
|
--> tests/fail/dangling_pointers/null_pointer_deref.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x: i32 = unsafe { *std::ptr::null() };
|
LL | let x: i32 = unsafe { *std::ptr::null() };
|
||||||
| ^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to 4 bytes of memory, but got a null pointer
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got null pointer
|
||||||
--> tests/fail/dangling_pointers/null_pointer_write.rs:LL:CC
|
--> tests/fail/dangling_pointers/null_pointer_write.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | unsafe { *std::ptr::null_mut() = 0i32 };
|
LL | unsafe { *std::ptr::null_mut() = 0i32 };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ fn main() {
|
|||||||
let ptr = addr_of!(v).cast::<(u32, u32, u32)>();
|
let ptr = addr_of!(v).cast::<(u32, u32, u32)>();
|
||||||
unsafe {
|
unsafe {
|
||||||
let _field = addr_of!((*ptr).1); // still just in-bounds
|
let _field = addr_of!((*ptr).1); // still just in-bounds
|
||||||
let _field = addr_of!((*ptr).2); //~ ERROR: out-of-bounds pointer arithmetic
|
let _field = addr_of!((*ptr).2); //~ ERROR: in-bounds pointer arithmetic failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC which is only 4 bytes from the end of the allocation
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC which is only 4 bytes from the end of the allocation
|
||||||
--> tests/fail/dangling_pointers/out_of_bounds_project.rs:LL:CC
|
--> tests/fail/dangling_pointers/out_of_bounds_project.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _field = addr_of!((*ptr).2);
|
LL | let _field = addr_of!((*ptr).2);
|
||||||
| ^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC which is only 4 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC which is only 4 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let v: Vec<u16> = vec![1, 2];
|
let v: Vec<u16> = vec![1, 2];
|
||||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
// 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: expected a pointer to 2 bytes of memory
|
let x = unsafe { *v.as_ptr().wrapping_byte_add(5) }; //~ ERROR: attempting to access 2 bytes
|
||||||
panic!("this should never print: {}", x);
|
panic!("this should never print: {}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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
|
error: Undefined Behavior: memory access failed: attempting to access 2 bytes, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||||
--> tests/fail/dangling_pointers/out_of_bounds_read.rs:LL:CC
|
--> tests/fail/dangling_pointers/out_of_bounds_read.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { *v.as_ptr().wrapping_byte_add(5) };
|
LL | let x = unsafe { *v.as_ptr().wrapping_byte_add(5) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 2 bytes, 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: 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut v: Vec<u16> = vec![1, 2];
|
let mut v: Vec<u16> = vec![1, 2];
|
||||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
// 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: expected a pointer to 2 bytes of memory
|
unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 }; //~ ERROR: attempting to access 2 bytes
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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
|
error: Undefined Behavior: memory access failed: attempting to access 2 bytes, but got ALLOC+0x5 which is at or beyond the end of the allocation of size 4 bytes
|
||||||
--> tests/fail/dangling_pointers/out_of_bounds_write.rs:LL:CC
|
--> tests/fail/dangling_pointers/out_of_bounds_write.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 };
|
LL | unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 2 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/dangling_pointers/storage_dead_dangling.rs:LL:CC
|
--> tests/fail/dangling_pointers/storage_dead_dangling.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _ref = unsafe { &mut *(LEAK as *mut i32) };
|
LL | let _ref = unsafe { &mut *(LEAK as *mut i32) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must be dereferenceable for 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/dangling_pointers/wild_pointer_deref.rs:LL:CC
|
--> tests/fail/dangling_pointers/wild_pointer_deref.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { *p };
|
LL | let x = unsafe { *p };
|
||||||
| ^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/function_pointers/cast_int_to_fn_ptr.rs:LL:CC
|
--> tests/fail/function_pointers/cast_int_to_fn_ptr.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | g(42)
|
LL | g(42)
|
||||||
| ^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^ pointer not dereferenceable: pointer must point 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: 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
|
= 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: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/intrinsics/ptr_offset_int_plus_int.rs:LL:CC
|
--> tests/fail/intrinsics/ptr_offset_int_plus_int.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = (1 as *mut u8).offset(1);
|
LL | let _val = (1 as *mut u8).offset(1);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, 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: 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
|
= 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: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs:LL:CC
|
--> tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = (1 as *mut u8).offset(ptr as isize);
|
LL | let _val = (1 as *mut u8).offset(ptr as isize);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, 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: 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let v = [0i8; 4];
|
let v = [0i8; 4];
|
||||||
let x = &v as *const i8;
|
let x = &v as *const i8;
|
||||||
let x = unsafe { x.offset(5) }; //~ERROR: expected a pointer to 5 bytes of memory
|
let x = unsafe { x.offset(5) }; //~ERROR: is only 4 bytes from the end of the allocation
|
||||||
panic!("this should never print: {:?}", x);
|
panic!("this should never print: {:?}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to 5 bytes of memory, but got ALLOC which is only 4 bytes from the end of the allocation
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 5 bytes, but got ALLOC which is only 4 bytes from the end of the allocation
|
||||||
--> tests/fail/intrinsics/ptr_offset_out_of_bounds.rs:LL:CC
|
--> tests/fail/intrinsics/ptr_offset_out_of_bounds.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { x.offset(5) };
|
LL | let x = unsafe { x.offset(5) };
|
||||||
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 5 bytes of memory, but got ALLOC which is only 4 bytes from the end of the allocation
|
| ^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 5 bytes, but got ALLOC which is only 4 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let v = [0i8; 4];
|
let v = [0i8; 4];
|
||||||
let x = &v as *const i8;
|
let x = &v as *const i8;
|
||||||
let x = unsafe { x.offset(-1) }; //~ERROR: expected a pointer to the end of 1 byte of memory
|
let x = unsafe { x.offset(-1) }; //~ERROR: is at the beginning of the allocation
|
||||||
panic!("this should never print: {:?}", x);
|
panic!("this should never print: {:?}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC which is at the beginning of the allocation
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by -1 bytes, but got ALLOC which is at the beginning of the allocation
|
||||||
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg.rs:LL:CC
|
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { x.offset(-1) };
|
LL | let x = unsafe { x.offset(-1) };
|
||||||
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC which is at the beginning of the allocation
|
| ^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -1 bytes, but got ALLOC which is at the beginning of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let v = [0i8; 4];
|
let v = [0i8; 4];
|
||||||
let x = &v as *const i8;
|
let x = &v as *const i8;
|
||||||
let x = unsafe { x.offset(isize::MIN) }; //~ERROR: out-of-bounds pointer arithmetic
|
let x = unsafe { x.offset(isize::MIN) }; //~ERROR: in-bounds pointer arithmetic failed
|
||||||
panic!("this should never print: {:?}", x);
|
panic!("this should never print: {:?}", x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC which is at the beginning of the allocation
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC which is at the beginning of the allocation
|
||||||
--> tests/fail/intrinsics/ptr_offset_overflow.rs:LL:CC
|
--> tests/fail/intrinsics/ptr_offset_overflow.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = unsafe { x.offset(isize::MIN) };
|
LL | let x = unsafe { x.offset(isize::MIN) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC which is at the beginning of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC which is at the beginning of the allocation
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ fn main() {
|
|||||||
let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18];
|
let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18];
|
||||||
let idxs = Simd::from_array([9, 3, 0, 17]);
|
let idxs = Simd::from_array([9, 3, 0, 17]);
|
||||||
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
||||||
//~^ERROR: expected a pointer to 1 byte of memory
|
//~^ERROR: attempting to access 1 byte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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
|
error: Undefined Behavior: memory access failed: attempting to access 1 byte, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||||
--> tests/fail/intrinsics/simd-gather.rs:LL:CC
|
--> tests/fail/intrinsics/simd-gather.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, 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: 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
|
= 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 mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
|
||||||
let idxs = Simd::from_array([9, 3, 0, 17]);
|
let idxs = Simd::from_array([9, 3, 0, 17]);
|
||||||
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
||||||
//~^ERROR: expected a pointer to 1 byte of memory
|
//~^ERROR: attempting to access 1 byte
|
||||||
&mut vec,
|
&mut vec,
|
||||||
Mask::splat(true),
|
Mask::splat(true),
|
||||||
idxs,
|
idxs,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
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
|
error: Undefined Behavior: memory access failed: attempting to access 1 byte, but got ALLOC+0x9 which is at or beyond the end of the allocation of size 9 bytes
|
||||||
--> tests/fail/intrinsics/simd-scatter.rs:LL:CC
|
--> tests/fail/intrinsics/simd-scatter.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | / Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
LL | / Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
|
||||||
@@ -7,7 +7,7 @@ LL | | &mut vec,
|
|||||||
LL | | Mask::splat(true),
|
LL | | Mask::splat(true),
|
||||||
LL | | idxs,
|
LL | | idxs,
|
||||||
LL | | );
|
LL | | );
|
||||||
| |_________^ 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
|
| |_________^ memory access failed: attempting to access 1 byte, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/int_copy_looses_provenance3.rs:LL:CC
|
--> tests/fail/provenance/int_copy_looses_provenance3.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = unsafe { *ptr };
|
LL | let _val = unsafe { *ptr };
|
||||||
| ^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/pointer_partial_overwrite.rs:LL:CC
|
--> tests/fail/provenance/pointer_partial_overwrite.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let x = *p;
|
LL | let x = *p;
|
||||||
| ^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 1 byte, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/provenance_transmute.rs:LL:CC
|
--> tests/fail/provenance/provenance_transmute.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = *left_ptr;
|
LL | let _val = *left_ptr;
|
||||||
| ^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^ memory access failed: attempting to access 1 byte, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/ptr_copy_loses_partial_provenance0.rs:LL:CC
|
--> tests/fail/provenance/ptr_copy_loses_partial_provenance0.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = *ptr;
|
LL | let _val = *ptr;
|
||||||
| ^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/ptr_copy_loses_partial_provenance1.rs:LL:CC
|
--> tests/fail/provenance/ptr_copy_loses_partial_provenance1.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = *ptr;
|
LL | let _val = *ptr;
|
||||||
| ^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/ptr_int_unexposed.rs:LL:CC
|
--> tests/fail/provenance/ptr_int_unexposed.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | assert_eq!(unsafe { *ptr }, 3);
|
LL | assert_eq!(unsafe { *ptr }, 3);
|
||||||
| ^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 4 bytes, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/ptr_invalid.rs:LL:CC
|
--> tests/fail/provenance/ptr_invalid.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = unsafe { *xptr_invalid };
|
LL | let _val = unsafe { *xptr_invalid };
|
||||||
| ^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, 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: 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
|
= 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: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/provenance/ptr_invalid_offset.rs:LL:CC
|
--> tests/fail/provenance/ptr_invalid_offset.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _ = unsafe { roundtrip.offset(1) };
|
LL | let _ = unsafe { roundtrip.offset(1) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, 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: 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
|
= 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 been freed, so this pointer is dangling
|
error: Undefined Behavior: pointer not dereferenceable: ALLOC has been freed, so this pointer is dangling
|
||||||
--> tests/fail/rc_as_ptr.rs:LL:CC
|
--> tests/fail/rc_as_ptr.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | assert_eq!(42, **unsafe { &*Weak::as_ptr(&weak) });
|
LL | assert_eq!(42, **unsafe { &*Weak::as_ptr(&weak) });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: ALLOC has been freed, so this pointer is dangling
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: ALLOC has been freed, so this pointer is dangling
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= 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: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: attempting to access 1 byte, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
--> tests/fail/reading_half_a_pointer.rs:LL:CC
|
--> tests/fail/reading_half_a_pointer.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = *x;
|
LL | let _val = *x;
|
||||||
| ^^ memory access failed: expected a pointer to 1 byte of memory, but got $HEX[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^ memory access failed: attempting to access 1 byte, 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: 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ extern "Rust" {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
miri_resolve_frame(std::ptr::null_mut(), 0); //~ ERROR: got a null pointer
|
miri_resolve_frame(std::ptr::null_mut(), 0); //~ ERROR: null pointer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error: Undefined Behavior: out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
error: Undefined Behavior: pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
--> tests/fail/shims/backtrace/bad-backtrace-ptr.rs:LL:CC
|
--> tests/fail/shims/backtrace/bad-backtrace-ptr.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | miri_resolve_frame(std::ptr::null_mut(), 0);
|
LL | miri_resolve_frame(std::ptr::null_mut(), 0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer use: expected a pointer to some allocation, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pointer not dereferenceable: pointer must point to some allocation, but got null pointer
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
// make sure ZST locals cannot be accessed
|
// make sure ZST locals cannot be accessed
|
||||||
let x = &() as *const () as *const i8;
|
let x = &() as *const () as *const i8;
|
||||||
let _val = unsafe { *x }; //~ ERROR: expected a pointer to 1 byte of memory
|
let _val = unsafe { *x }; //~ ERROR: attempting to access 1 byte
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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
|
error: Undefined Behavior: memory access failed: attempting to access 1 byte, but got ALLOC which is at or beyond the end of the allocation of size 0 bytes
|
||||||
--> tests/fail/zst_local_oob.rs:LL:CC
|
--> tests/fail/zst_local_oob.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | let _val = unsafe { *x };
|
LL | let _val = unsafe { *x };
|
||||||
| ^^ 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
|
| ^^ memory access failed: attempting to access 1 byte, 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: 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
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
--> $DIR/forbidden_slices.rs:54:25
|
--> $DIR/forbidden_slices.rs:54:25
|
||||||
|
|
|
|
||||||
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
|
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
|
||||||
| ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation
|
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
|
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -169,7 +169,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
--> $DIR/forbidden_slices.rs:79:25
|
--> $DIR/forbidden_slices.rs:79:25
|
||||||
|
|
|
|
||||||
LL | from_ptr_range(ptr..ptr.add(1))
|
LL | from_ptr_range(ptr..ptr.add(1))
|
||||||
| ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
|
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
|
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/out_of_bounds_read.rs:8:33
|
--> $DIR/out_of_bounds_read.rs:8:33
|
||||||
|
|
|
|
||||||
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
|
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::read::<u32>`
|
note: inside `std::ptr::read::<u32>`
|
||||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||||
@@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/out_of_bounds_read.rs:10:39
|
--> $DIR/out_of_bounds_read.rs:10:39
|
||||||
|
|
|
|
||||||
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
|
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
|
||||||
| ^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
|
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -22,7 +22,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/out_of_bounds_read.rs:12:37
|
--> $DIR/out_of_bounds_read.rs:12:37
|
||||||
|
|
|
|
||||||
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
|
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
|
note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
|
||||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||||
|
|||||||
@@ -2,31 +2,31 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/const-compare-bytes-ub.rs:9:9
|
--> $DIR/const-compare-bytes-ub.rs:9:9
|
||||||
|
|
|
|
||||||
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
|
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got a null pointer
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got null pointer
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-compare-bytes-ub.rs:13:9
|
--> $DIR/const-compare-bytes-ub.rs:13:9
|
||||||
|
|
|
|
||||||
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
|
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-compare-bytes-ub.rs:17:9
|
--> $DIR/const-compare-bytes-ub.rs:17:9
|
||||||
|
|
|
|
||||||
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
|
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-compare-bytes-ub.rs:21:9
|
--> $DIR/const-compare-bytes-ub.rs:21:9
|
||||||
|
|
|
|
||||||
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
|
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0 which is only 3 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-compare-bytes-ub.rs:25:9
|
--> $DIR/const-compare-bytes-ub.rs:25:9
|
||||||
|
|
|
|
||||||
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
|
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC1 which is only 3 bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const-compare-bytes-ub.rs:29:9
|
--> $DIR/const-compare-bytes-ub.rs:29:9
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
|
|||||||
--> $DIR/const-deref-ptr.rs:4:29
|
--> $DIR/const-deref-ptr.rs:4:29
|
||||||
|
|
|
|
||||||
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
|
LL | static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 8 bytes, but got 0xdeadbeef[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ const Z: i32 = unsafe { *(&1 as *const i32) };
|
|||||||
|
|
||||||
// bad, will thus error in miri
|
// bad, will thus error in miri
|
||||||
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed
|
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR evaluation of constant value failed
|
||||||
//~| NOTE is a dangling pointer
|
//~| NOTE dangling pointer
|
||||||
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed
|
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR evaluation of constant value failed
|
||||||
//~| NOTE is a dangling pointer
|
//~| NOTE dangling pointer
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/const_raw_ptr_ops2.rs:7:26
|
--> $DIR/const_raw_ptr_ops2.rs:7:26
|
||||||
|
|
|
|
||||||
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
|
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2a[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/const_raw_ptr_ops2.rs:9:26
|
--> $DIR/const_raw_ptr_ops2.rs:9:26
|
||||||
|
|
|
|
||||||
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
|
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
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
|
--> $DIR/nonnull_as_ref_ub.rs:4:29
|
||||||
|
|
|
|
||||||
LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() });
|
LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() });
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 1 byte of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const OOB: () = unsafe {
|
|||||||
let mem = [0u32; 1];
|
let mem = [0u32; 1];
|
||||||
let ptr = mem.as_ptr().cast::<u64>();
|
let ptr = mem.as_ptr().cast::<u64>();
|
||||||
let _val = *ptr; //~ERROR: evaluation of constant value failed
|
let _val = *ptr; //~ERROR: evaluation of constant value failed
|
||||||
//~^NOTE: expected a pointer to 8 bytes of memory
|
//~^NOTE: is only 4 bytes from the end of the allocation
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/raw-pointer-ub.rs:41:16
|
--> $DIR/raw-pointer-ub.rs:41:16
|
||||||
|
|
|
|
||||||
LL | let _val = *ptr;
|
LL | let _val = *ptr;
|
||||||
| ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 which is only 4 bytes from the end of the allocation
|
| ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/ub-nonnull.rs:20:29
|
--> $DIR/ub-nonnull.rs:20:29
|
||||||
|
|
|
|
||||||
LL | let out_of_bounds_ptr = &ptr[255];
|
LL | let out_of_bounds_ptr = &ptr[255];
|
||||||
| ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation
|
| ^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 255 bytes, but got ALLOC1 which is only 1 byte from the end of the allocation
|
||||||
|
|
||||||
error[E0080]: it is undefined behavior to use this value
|
error[E0080]: it is undefined behavior to use this value
|
||||||
--> $DIR/ub-nonnull.rs:24:1
|
--> $DIR/ub-nonnull.rs:24:1
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const COPY_OOB_1: () = unsafe {
|
|||||||
copy_nonoverlapping(0x100 as *const i32, dangle, 0);
|
copy_nonoverlapping(0x100 as *const i32, dangle, 0);
|
||||||
// Non-zero-sized copy is not.
|
// Non-zero-sized copy is not.
|
||||||
copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR evaluation of constant value failed [E0080]
|
copy_nonoverlapping(0x100 as *const i32, dangle, 1); //~ ERROR evaluation of constant value failed [E0080]
|
||||||
//~| NOTE got 0x100[noalloc] which is a dangling pointer
|
//~| NOTE which is a dangling pointer
|
||||||
};
|
};
|
||||||
const COPY_OOB_2: () = unsafe {
|
const COPY_OOB_2: () = unsafe {
|
||||||
let x = 0i32;
|
let x = 0i32;
|
||||||
@@ -41,7 +41,7 @@ const COPY_OOB_2: () = unsafe {
|
|||||||
copy_nonoverlapping(dangle, 0x100 as *mut i32, 0);
|
copy_nonoverlapping(dangle, 0x100 as *mut i32, 0);
|
||||||
// Non-zero-sized copy is not.
|
// Non-zero-sized copy is not.
|
||||||
copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR evaluation of constant value failed [E0080]
|
copy_nonoverlapping(dangle, 0x100 as *mut i32, 1); //~ ERROR evaluation of constant value failed [E0080]
|
||||||
//~| NOTE +0x28 which is at or beyond the end of the allocation
|
//~| NOTE is at or beyond the end of the allocation of size 4 bytes
|
||||||
};
|
};
|
||||||
|
|
||||||
const COPY_SIZE_OVERFLOW: () = unsafe {
|
const COPY_SIZE_OVERFLOW: () = unsafe {
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/copy-intrinsic.rs:34:5
|
--> $DIR/copy-intrinsic.rs:34:5
|
||||||
|
|
|
|
||||||
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
|
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got 0x100[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got 0x100[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/copy-intrinsic.rs:43:5
|
--> $DIR/copy-intrinsic.rs:43:5
|
||||||
|
|
|
|
||||||
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
|
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, 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
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/copy-intrinsic.rs:50:5
|
--> $DIR/copy-intrinsic.rs:50:5
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:8:46
|
--> $DIR/offset_ub.rs:8:46
|
||||||
|
|
|
|
||||||
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
|
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC0 which is at the beginning of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:9:43
|
--> $DIR/offset_ub.rs:9:43
|
||||||
|
|
|
|
||||||
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
|
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:10:45
|
--> $DIR/offset_ub.rs:10:45
|
||||||
|
|
|
|
||||||
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
|
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2 which is only $BYTES bytes from the end of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -47,7 +47,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:14:56
|
--> $DIR/offset_ub.rs:14:56
|
||||||
|
|
|
|
||||||
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
|
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -56,7 +56,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:15:57
|
--> $DIR/offset_ub.rs:15:57
|
||||||
|
|
|
|
||||||
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
|
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -65,7 +65,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:16:49
|
--> $DIR/offset_ub.rs:16:49
|
||||||
|
|
|
|
||||||
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
|
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC3-0x2 which points to before the beginning of the allocation
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -74,7 +74,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:18:50
|
--> $DIR/offset_ub.rs:18:50
|
||||||
|
|
|
|
||||||
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
|
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
@@ -83,7 +83,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:19:42
|
--> $DIR/offset_ub.rs:19:42
|
||||||
|
|
|
|
||||||
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
|
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset`
|
note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||||
@@ -92,7 +92,7 @@ error[E0080]: evaluation of constant value failed
|
|||||||
--> $DIR/offset_ub.rs:22:47
|
--> $DIR/offset_ub.rs:22:47
|
||||||
|
|
|
|
||||||
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
|
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
||||||
|
|
|
|
||||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||||
|
|||||||
Reference in New Issue
Block a user