From ce35d4ca81e7ef02498c18d7f284143079b5f03c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 23 Oct 2025 08:56:00 +0200 Subject: [PATCH] SB wildcard handling: extend comments --- .../miri/src/borrow_tracker/stacked_borrows/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs index 127d832f73e7..488de363bbe0 100644 --- a/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs +++ b/src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs @@ -675,16 +675,22 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> { if let Ok((alloc_id, base_offset, orig_tag)) = this.ptr_try_get_alloc_id(place.ptr(), 0) { log_creation(this, Some((alloc_id, base_offset, orig_tag)))?; - // Still give it the new provenance, it got retagged after all. + // Still give it the new provenance, it got retagged after all. If this was a + // wildcard pointer, this will fix the AllocId and make future accesses with this + // reference to other allocations UB, but that's fine: due to subobject provenance, + // *all* future accesses with this reference should be UB! return interp_ok(Some(Provenance::Concrete { alloc_id, tag: new_tag })); } else { // This pointer doesn't come with an AllocId. :shrug: log_creation(this, None)?; - // Provenance unchanged. + // Provenance unchanged. Ideally we'd make this pointer UB to use like above, + // but there's no easy way to do that. return interp_ok(place.ptr().provenance); } } + // The pointer *must* have a valid AllocId to continue, so we want to resolve this to + // a concrete ID even for wildcard pointers. let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr(), 0)?; log_creation(this, Some((alloc_id, base_offset, orig_tag)))?;