diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-13 15:15:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-13 15:15:58 +0200 |
| commit | 762b3143fca8bc76d70eef15581f73315af77ef8 (patch) | |
| tree | 522aa3f0a4dbd4f20710a2bc130fbcb85d241bb3 /src | |
| parent | 061bd28ceeebf03cb779b10ad1966ec868b1f153 (diff) | |
| parent | 8d0e0c6d6fae36283c11535dcb88b52baf286fc5 (diff) | |
| download | rust-762b3143fca8bc76d70eef15581f73315af77ef8.tar.gz rust-762b3143fca8bc76d70eef15581f73315af77ef8.zip | |
Rollup merge of #143634 - nia-e:init-and-wildcards, r=RalfJung
interpret/allocation: expose init + write_wildcards on a range Part of https://github.com/rust-lang/miri/pull/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`````
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/shims/native_lib/mod.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/miri/src/shims/native_lib/mod.rs b/src/tools/miri/src/shims/native_lib/mod.rs index 9b30d8ce78b..02c3bde036d 100644 --- a/src/tools/miri/src/shims/native_lib/mod.rs +++ b/src/tools/miri/src/shims/native_lib/mod.rs @@ -231,7 +231,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { .collect::<Vec<libffi::high::Arg<'_>>>(); // Prepare all exposed memory (both previously exposed, and just newly exposed since a - // pointer was passed as argument). + // pointer was passed as argument). Uninitialised memory is left as-is, but any data + // exposed this way is garbage anyway. this.visit_reachable_allocs(this.exposed_allocs(), |this, alloc_id, info| { // If there is no data behind this pointer, skip this. if !matches!(info.kind, AllocKind::LiveData) { @@ -251,8 +252,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // Prepare for possible write from native code if mutable. if info.mutbl.is_mut() { - let alloc = &mut this.get_alloc_raw_mut(alloc_id)?.0; - alloc.prepare_for_native_access(); + let (alloc, cx) = this.get_alloc_raw_mut(alloc_id)?; + alloc.process_native_write(&cx.tcx, None); // Also expose *mutable* provenance for the interpreter-level allocation. std::hint::black_box(alloc.get_bytes_unchecked_raw_mut().expose_provenance()); } |
