1
Fork 0

Rollup merge of #98860 - RalfJung:dangling-int-ptr, r=davidtwco

adjust dangling-int-ptr error message

based on suggestions by `@saethlin` in https://github.com/rust-lang/miri/issues/2163

Fixes https://github.com/rust-lang/miri/issues/2163

I also did a bit of refactoring on this, so we have a helper method to create a `Pointer` with `None` provenance.
This commit is contained in:
Matthias Krüger 2022-07-05 17:08:10 +02:00 committed by GitHub
commit 69195c026e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 60 additions and 47 deletions

View file

@ -513,7 +513,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
_ecx: &InterpCx<$mir, $tcx, Self>,
addr: u64,
) -> Pointer<Option<AllocId>> {
Pointer::new(None, Size::from_bytes(addr))
Pointer::from_addr(addr)
}
#[inline(always)]
@ -523,7 +523,7 @@ pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
) -> InterpResult<$tcx, Pointer<Option<AllocId>>> {
// Allow these casts, but make the pointer not dereferenceable.
// (I.e., they behave like transmutation.)
Ok(Pointer::new(None, Size::from_bytes(addr)))
Ok(Pointer::from_addr(addr))
}
#[inline(always)]

View file

@ -188,7 +188,7 @@ impl<'tcx, Tag: Provenance> MPlaceTy<'tcx, Tag> {
#[inline]
pub fn dangling(layout: TyAndLayout<'tcx>) -> Self {
let align = layout.align.abi;
let ptr = Pointer::new(None, Size::from_bytes(align.bytes())); // no provenance, absolute address
let ptr = Pointer::from_addr(align.bytes()); // no provenance, absolute address
// `Poison` this to make sure that the pointer value `ptr` is never observable by the program.
MPlaceTy { mplace: MemPlace { ptr, meta: MemPlaceMeta::Poison }, layout, align }
}