about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-03-11 14:32:03 +0100
committerRalf Jung <post@ralfj.de>2025-03-11 14:34:21 +0100
commit3846f942300c4fd8f43a8a8a1324ad5e358b9459 (patch)
treec14bf2a8834a19706226a407844c717cc15e54e9 /compiler/rustc_const_eval/src
parent705421b52239d7393b4738764b192179d5c139c2 (diff)
downloadrust-3846f942300c4fd8f43a8a8a1324ad5e358b9459.tar.gz
rust-3846f942300c4fd8f43a8a8a1324ad5e358b9459.zip
miri native_calls: ensure we actually expose *mutable* provenance to the memory FFI can access
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs
index ce0b5a350e0..e5af0673629 100644
--- a/compiler/rustc_const_eval/src/interpret/memory.rs
+++ b/compiler/rustc_const_eval/src/interpret/memory.rs
@@ -982,6 +982,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
                     todo.push(id);
                 }
             }
+            // Also expose the provenance of the interpreter-level allocation, so it can
+            // be read by FFI. The `black_box` is defensive programming as LLVM likes
+            // to (incorrectly) optimize away ptr2int casts whose result is unused.
+            std::hint::black_box(alloc.get_bytes_unchecked_raw().expose_provenance());
 
             // Prepare for possible write from native code if mutable.
             if info.mutbl.is_mut() {