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> {
176
176
let base_addr = if ecx. machine . native_lib . is_some ( ) {
177
177
match kind {
178
178
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 ( ) {
180
180
// For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
181
181
let prepared_bytes = MiriAllocBytes :: zeroed ( size, align)
182
182
. unwrap_or_else ( || {
183
183
panic ! ( "Miri ran out of memory: cannot create allocation of {size:?} bytes" )
184
184
} ) ;
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
189
189
} 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 ( )
192
194
}
193
195
AllocKind :: Function | AllocKind :: VTable => {
194
196
// Allocate some dummy memory to get a unique address for this function/vtable.
Original file line number Diff line number Diff line change 13
13
#![ feature( trait_upcasting) ]
14
14
#![ feature( strict_overflow_ops) ]
15
15
#![ feature( strict_provenance) ]
16
+ #![ feature( exposed_provenance) ]
16
17
// Configure clippy and other lints
17
18
#![ allow(
18
19
clippy:: collapsible_else_if,
You can’t perform that action at this time.
0 commit comments