about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-10-19 22:32:42 +0200
committerRalf Jung <post@ralfj.de>2023-10-19 22:32:42 +0200
commitecaf828e131535f4268bc2e76d2e83bcfe3b682d (patch)
treee77ff737b6490d32f50b8f97fd531b67ff6b94be /src
parentb325f31f6641024cfbfa9cd9a168fec3db088f41 (diff)
downloadrust-ecaf828e131535f4268bc2e76d2e83bcfe3b682d.tar.gz
rust-ecaf828e131535f4268bc2e76d2e83bcfe3b682d.zip
clarify comment
Diffstat (limited to 'src')
-rw-r--r--src/tools/miri/src/intptrcast.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/tools/miri/src/intptrcast.rs b/src/tools/miri/src/intptrcast.rs
index 9e813d58395..ab6a256f714 100644
--- a/src/tools/miri/src/intptrcast.rs
+++ b/src/tools/miri/src/intptrcast.rs
@@ -275,9 +275,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
 
 impl GlobalStateInner {
     pub fn free_alloc_id(&mut self, dead_id: AllocId) {
-        // We can *not* remove this from `base_addr`, since `addr_from_alloc_id` is called on each
-        // attempt at a memory access to determine the allocation ID and offset -- and there can
-        // still be pointers with `dead_id` that one can attempt to use for a memory access.
+        // We can *not* remove this from `base_addr`, since the interpreter design requires that we
+        // be able to retrieve an AllocId + offset for any memory access *before* we check if the
+        // access is valid. Specifically, `ptr_get_alloc` is called on each attempt at a memory
+        // access to determine the allocation ID and offset -- and there can still be pointers with
+        // `dead_id` that one can attempt to use for a memory access. `ptr_get_alloc` may return
+        // `None` only if the pointer truly has no provenance (this ensures consistent error
+        // messages).
         // However, we *can* remove it from `int_to_ptr_map`, since any wildcard pointers that exist
         // can no longer actually be accessing that address. This ensures `alloc_id_from_addr` never
         // returns a dead allocation.