commit
4e329ebab7
4 changed files with 9 additions and 9 deletions
|
|
@ -1 +1 @@
|
|||
d35181ad8785fa958e43580a29a982afe02c728f
|
||||
1a56ec4dae92538ab6e0ecf993c61f3b50ed77cf
|
||||
|
|
|
|||
|
|
@ -158,8 +158,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
// Dead allocations in miri cannot overlap with live allocations, but
|
||||
// on read hardware this can easily happen. Thus for comparisons we require
|
||||
// both pointers to be live.
|
||||
self.memory().check_bounds_ptr(left, InboundsCheck::Live)?;
|
||||
self.memory().check_bounds_ptr(right, InboundsCheck::Live)?;
|
||||
self.memory().check_bounds_ptr(left, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
|
||||
self.memory().check_bounds_ptr(right, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
|
||||
// Two in-bounds pointers, we can compare across allocations.
|
||||
left == right
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
if bits < 32 {
|
||||
// Test if the ptr is in-bounds. Then it cannot be NULL.
|
||||
// Even dangling pointers cannot be NULL.
|
||||
if self.memory().check_bounds_ptr(ptr, InboundsCheck::MaybeDead).is_ok() {
|
||||
if self.memory().check_bounds_ptr(ptr, InboundsCheck::MaybeDead, CheckInAllocMsg::NullPointerTest).is_ok() {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -340,9 +340,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
|
|||
if let Scalar::Ptr(ptr) = ptr {
|
||||
// Both old and new pointer must be in-bounds of a *live* allocation.
|
||||
// (Of the same allocation, but that part is trivial with our representation.)
|
||||
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
|
||||
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
|
||||
let ptr = ptr.signed_offset(offset, self)?;
|
||||
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live)?;
|
||||
self.memory().check_bounds_ptr(ptr, InboundsCheck::Live, CheckInAllocMsg::InboundsTest)?;
|
||||
Ok(Scalar::Ptr(ptr))
|
||||
} else {
|
||||
// An integer pointer. They can only be offset by 0, and we pretend there
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use rustc::mir::RetagKind;
|
|||
|
||||
use crate::{
|
||||
EvalResult, InterpError, MiriEvalContext, HelpersEvalContextExt, Evaluator, MutValueVisitor,
|
||||
MemoryKind, MiriMemoryKind, RangeMap, Allocation, AllocationExtra,
|
||||
MemoryKind, MiriMemoryKind, RangeMap, Allocation, AllocationExtra, CheckInAllocMsg,
|
||||
Pointer, Immediate, ImmTy, PlaceTy, MPlaceTy,
|
||||
};
|
||||
|
||||
|
|
@ -550,7 +550,7 @@ trait EvalContextPrivExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
|
|||
|
||||
// Get the allocation. It might not be mutable, so we cannot use `get_mut`.
|
||||
let alloc = this.memory().get(ptr.alloc_id)?;
|
||||
alloc.check_bounds(this, ptr, size)?;
|
||||
alloc.check_bounds(this, ptr, size, CheckInAllocMsg::InboundsTest)?;
|
||||
// Update the stacks.
|
||||
// Make sure that raw pointers and mutable shared references are reborrowed "weak":
|
||||
// There could be existing unique pointers reborrowed from them that should remain valid!
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// error-pattern: must be in-bounds and live at offset 5, but is outside bounds of allocation
|
||||
// error-pattern: must be in-bounds at offset 5, but is outside bounds of allocation
|
||||
fn main() {
|
||||
let v = [0i8; 4];
|
||||
let x = &v as *const i8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue