Skip to content

Commit a18c57e

Browse files
authored
Rollup merge of #143634 - nia-e:init-and-wildcards, r=RalfJung
interpret/allocation: expose init + write_wildcards on a range Part of #4456, so that we can mark down when a foreign access to our memory happened. Should this also move `prepare_for_native_access()` itself into Miri, given that everything there can be implemented on Miri's side? r? `````@RalfJung`````
2 parents 2f95325 + b0f6d77 commit a18c57e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/shims/native_lib/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
231231
.collect::<Vec<libffi::high::Arg<'_>>>();
232232

233233
// Prepare all exposed memory (both previously exposed, and just newly exposed since a
234-
// pointer was passed as argument).
234+
// pointer was passed as argument). Uninitialised memory is left as-is, but any data
235+
// exposed this way is garbage anyway.
235236
this.visit_reachable_allocs(this.exposed_allocs(), |this, alloc_id, info| {
236237
// If there is no data behind this pointer, skip this.
237238
if !matches!(info.kind, AllocKind::LiveData) {
@@ -251,8 +252,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
251252

252253
// Prepare for possible write from native code if mutable.
253254
if info.mutbl.is_mut() {
254-
let alloc = &mut this.get_alloc_raw_mut(alloc_id)?.0;
255-
alloc.prepare_for_native_access();
255+
let (alloc, cx) = this.get_alloc_raw_mut(alloc_id)?;
256+
alloc.process_native_write(&cx.tcx, None);
256257
// Also expose *mutable* provenance for the interpreter-level allocation.
257258
std::hint::black_box(alloc.get_bytes_unchecked_raw_mut().expose_provenance());
258259
}

0 commit comments

Comments
 (0)