File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -176,19 +176,21 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
176176 let base_addr = if ecx. machine . native_lib . is_some ( ) {
177177 match kind {
178178 AllocKind :: LiveData => {
179- if ecx. tcx . try_get_global_alloc ( alloc_id) . is_some ( ) {
179+ let ptr = if ecx. tcx . try_get_global_alloc ( alloc_id) . is_some ( ) {
180180 // For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
181181 let prepared_bytes = MiriAllocBytes :: zeroed ( size, align)
182182 . unwrap_or_else ( || {
183183 panic ! ( "Miri ran out of memory: cannot create allocation of {size:?} bytes" )
184184 } ) ;
185- let addr = prepared_bytes. as_ptr ( ) . addr ( ) . try_into ( ) . unwrap ( ) ;
186- // Store prepared allocation space to be picked up for use later.
187- global_state. prepared_alloc_bytes . try_insert ( alloc_id, prepared_bytes) . unwrap ( ) ;
188- addr
185+ let ptr = prepared_bytes. as_ptr ( ) ;
186+ // Store prepared allocation space to be picked up for use later.
187+ global_state. prepared_alloc_bytes . try_insert ( alloc_id, prepared_bytes) . unwrap ( ) ;
188+ ptr
189189 } else {
190- ecx. get_alloc_bytes_unchecked_raw ( alloc_id) ?. addr ( ) . try_into ( ) . unwrap ( )
191- }
190+ ecx. get_alloc_bytes_unchecked_raw ( alloc_id) ?
191+ } ;
192+ // Ensure this pointer's provenance is exposed, so that it can be used by FFI code.
193+ ptr. expose_provenance ( ) . try_into ( ) . unwrap ( )
192194 }
193195 AllocKind :: Function | AllocKind :: VTable => {
194196 // Allocate some dummy memory to get a unique address for this function/vtable.
Original file line number Diff line number Diff line change 1313#![ feature( trait_upcasting) ]
1414#![ feature( strict_overflow_ops) ]
1515#![ feature( strict_provenance) ]
16+ #![ feature( exposed_provenance) ]
1617// Configure clippy and other lints
1718#![ allow(
1819 clippy:: collapsible_else_if,
You can’t perform that action at this time.
0 commit comments