Skip to content

Commit 81df2af

Browse files
committed
Handle wildcard pointers in SB
1 parent e7507d6 commit 81df2af

File tree

7 files changed

+282
-88
lines changed

7 files changed

+282
-88
lines changed

src/machine.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
489489
type AllocExtra = AllocExtra;
490490

491491
type PointerTag = Tag;
492-
type TagExtra = SbTag;
492+
type TagExtra = Option<SbTag>;
493493

494494
type MemoryMap =
495495
MonoHashMap<AllocId, (MemoryKind<MiriMemoryKind>, Allocation<Tag, Self::AllocExtra>)>;
@@ -695,8 +695,24 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
695695
ptr: Pointer<Self::PointerTag>,
696696
) -> InterpResult<'tcx> {
697697
match ptr.provenance {
698-
Tag::Concrete(concrete) =>
699-
intptrcast::GlobalStateInner::expose_addr(ecx, concrete.alloc_id),
698+
Tag::Concrete(ConcreteTag { alloc_id, sb }) => {
699+
intptrcast::GlobalStateInner::expose_addr(ecx, alloc_id);
700+
701+
let (size, _) =
702+
ecx.get_alloc_size_and_align(alloc_id, AllocCheck::MaybeDead).unwrap();
703+
704+
// Function pointers and dead objects don't have an alloc_extra so we ignore them.
705+
if let Ok(alloc_extra) = ecx.get_alloc_extra(alloc_id) {
706+
if let Some(stacked_borrows) = &alloc_extra.stacked_borrows {
707+
stacked_borrows.ptr_exposed(
708+
alloc_id,
709+
sb,
710+
alloc_range(Size::from_bytes(0), size),
711+
ecx.machine.stacked_borrows.as_ref().unwrap(),
712+
)?;
713+
}
714+
}
715+
}
700716
Tag::Wildcard => {
701717
// No need to do anything for wildcard pointers as
702718
// their provenances have already been previously exposed.
@@ -715,8 +731,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
715731

716732
rel.map(|(alloc_id, size)| {
717733
let sb = match ptr.provenance {
718-
Tag::Concrete(ConcreteTag { sb, .. }) => sb,
719-
Tag::Wildcard => SbTag::Untagged,
734+
Tag::Concrete(ConcreteTag { sb, .. }) => Some(sb),
735+
Tag::Wildcard => None,
720736
};
721737
(alloc_id, size, sb)
722738
})

0 commit comments

Comments
 (0)