Skip to content

Commit ecaf828

Browse files
committed
clarify comment
1 parent b325f31 commit ecaf828

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/tools/miri/src/intptrcast.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
275275

276276
impl GlobalStateInner {
277277
pub fn free_alloc_id(&mut self, dead_id: AllocId) {
278-
// We can *not* remove this from `base_addr`, since `addr_from_alloc_id` is called on each
279-
// attempt at a memory access to determine the allocation ID and offset -- and there can
280-
// still be pointers with `dead_id` that one can attempt to use for a memory access.
278+
// We can *not* remove this from `base_addr`, since the interpreter design requires that we
279+
// be able to retrieve an AllocId + offset for any memory access *before* we check if the
280+
// access is valid. Specifically, `ptr_get_alloc` is called on each attempt at a memory
281+
// access to determine the allocation ID and offset -- and there can still be pointers with
282+
// `dead_id` that one can attempt to use for a memory access. `ptr_get_alloc` may return
283+
// `None` only if the pointer truly has no provenance (this ensures consistent error
284+
// messages).
281285
// However, we *can* remove it from `int_to_ptr_map`, since any wildcard pointers that exist
282286
// can no longer actually be accessing that address. This ensures `alloc_id_from_addr` never
283287
// returns a dead allocation.

0 commit comments

Comments
 (0)