1
Fork 0

Improve miri's error reporting in check_in_alloc

This commit is contained in:
LooMaclin 2019-04-19 02:26:57 +03:00
parent 15d50deeb4
commit a54e3cc9e7
2 changed files with 6 additions and 6 deletions

View file

@ -228,7 +228,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
// FIXME: Working around https://github.com/rust-lang/rust/issues/56209
where Extra: AllocationExtra<Tag, MemoryExtra>
{
self.get_bytes_internal(cx, ptr, size, true, CheckInAllocMsg::MemoryAccess)
self.get_bytes_internal(cx, ptr, size, true, CheckInAllocMsg::MemoryAccessTest)
}
/// It is the caller's responsibility to handle undefined and pointer bytes.
@ -243,7 +243,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
// FIXME: Working around https://github.com/rust-lang/rust/issues/56209
where Extra: AllocationExtra<Tag, MemoryExtra>
{
self.get_bytes_internal(cx, ptr, size, false, CheckInAllocMsg::MemoryAccess)
self.get_bytes_internal(cx, ptr, size, false, CheckInAllocMsg::MemoryAccessTest)
}
/// Just calling this already marks everything as defined and removes relocations,
@ -258,7 +258,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
where Extra: AllocationExtra<Tag, MemoryExtra>
{
assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccess)?;
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccessTest)?;
self.mark_definedness(ptr, size, true)?;
self.clear_relocations(cx, ptr, size)?;

View file

@ -461,9 +461,9 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
use self::InterpError::*;
match *self {
PointerOutOfBounds { ptr, msg, allocation_size } => {
write!(f, "{} test failed: pointer must be in-bounds at offset {}, but is outside bounds of \
allocation {} which has size {}", msg,
ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
write!(f, "{} test failed: pointer must be in-bounds at offset {}, \
but is outside bounds of allocation {} which has size {}",
msg, ptr.offset.bytes(), ptr.alloc_id, allocation_size.bytes())
},
ValidationFailure(ref err) => {
write!(f, "type validation failed: {}", err)