Skip to content

Commit b94890e

Browse files
committed
adjust for get_fn signature change
1 parent a034368 commit b94890e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/shims/foreign_items.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
317317
// vtable_ptr: *mut usize,
318318
// ) -> u32
319319
// We abort on panic, so not much is going on here, but we still have to call the closure.
320-
let f = this.read_scalar(args[0])?.to_ptr()?;
320+
let f = this.read_scalar(args[0])?.not_undef()?;
321321
let data = this.read_scalar(args[1])?.not_undef()?;
322322
let f_instance = this.memory().get_fn(f)?.as_instance()?;
323323
this.write_null(dest)?;
@@ -637,14 +637,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
637637
let key_ptr = this.read_scalar(args[0])?.not_undef()?;
638638

639639
// Extract the function type out of the signature (that seems easier than constructing it ourselves).
640-
let dtor = match this.read_scalar(args[1])?.not_undef()? {
641-
Scalar::Ptr(dtor_ptr) => Some(this.memory().get_fn(dtor_ptr)?.as_instance()?),
642-
Scalar::Raw { data: 0, size } => {
643-
// NULL pointer
644-
assert_eq!(size as u64, this.memory().pointer_size().bytes());
645-
None
646-
},
647-
Scalar::Raw { .. } => return err!(ReadBytesAsPointer),
640+
let dtor = match this.read_scalar(args[1])?.not_undef()?.to_bits_or_ptr(this.memory().pointer_size(), tcx) {
641+
Err(dtor_ptr) =>
642+
Some(this.memory().get_fn(dtor_ptr.into())?.as_instance()?),
643+
Ok(0) => // NULL pointer
644+
None,
645+
Ok(_) => return err!(ReadBytesAsPointer),
648646
};
649647

650648
// Figure out how large a pthread TLS key actually is.

0 commit comments

Comments
 (0)