Skip to content

Commit c18a276

Browse files
committed
miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access
1 parent eb2cfab commit c18a276

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/alloc_addresses/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
198198
}
199199
AllocKind::Dead => unreachable!(),
200200
};
201-
// Ensure this pointer's provenance is exposed, so that it can be used by FFI code.
202-
return interp_ok(base_ptr.expose_provenance().try_into().unwrap());
201+
// We don't have to expose this pointer yet, we do that in `prepare_for_native_call`.
202+
return interp_ok(base_ptr.addr().try_into().unwrap());
203203
}
204204
// We are not in native lib mode, so we control the addresses ourselves.
205205
if let Some((reuse_addr, clock)) = global_state.reuse.take_addr(

src/shims/native_lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn imm_to_carg<'tcx>(v: &ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'
266266
CArg::USize(v.to_scalar().to_target_usize(cx)?.try_into().unwrap()),
267267
ty::RawPtr(..) => {
268268
let s = v.to_scalar().to_pointer(cx)?.addr();
269-
// This relies on the `expose_provenance` in `addr_from_alloc_id`.
269+
// This relies on the `expose_provenance` in `prepare_for_native_call`.
270270
CArg::RawPtr(std::ptr::with_exposed_provenance_mut(s.bytes_usize()))
271271
}
272272
_ => throw_unsup_format!("unsupported argument type for native call: {}", v.layout.ty),

0 commit comments

Comments
 (0)