Skip to content

Commit 976a413

Browse files
committed
adjust for provenance cleanup
1 parent 9d47a56 commit 976a413

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

src/data_race.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,15 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
999999
if let Some(data_race) = &this.machine.data_race {
10001000
if data_race.multi_threaded.get() {
10011001
let size = place.layout.size;
1002-
let (alloc_id, base_offset, ptr) = this.ptr_get_alloc_id(place.ptr)?;
1002+
let (alloc_id, base_offset, _tag) = this.ptr_get_alloc_id(place.ptr)?;
10031003
// Load and log the atomic operation.
10041004
// Note that atomic loads are possible even from read-only allocations, so `get_alloc_extra_mut` is not an option.
10051005
let alloc_meta = &this.get_alloc_extra(alloc_id)?.data_race.as_ref().unwrap();
10061006
log::trace!(
10071007
"Atomic op({}) with ordering {:?} on {:?} (size={})",
10081008
description,
10091009
&atomic,
1010-
ptr,
1010+
place.ptr,
10111011
size.bytes()
10121012
);
10131013

@@ -1039,7 +1039,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
10391039
{
10401040
log::trace!(
10411041
"Updated atomic memory({:?}, size={}) to {:#?}",
1042-
ptr,
1042+
place.ptr,
10431043
size.bytes(),
10441044
range.atomic_ops
10451045
);

src/machine.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,13 @@ impl<'mir, 'tcx> MiriEvalContextExt<'mir, 'tcx> for MiriEvalContext<'mir, 'tcx>
431431
/// Machine hook implementations.
432432
impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
433433
type MemoryKind = MiriMemoryKind;
434+
type ExtraFnVal = Dlsym;
434435

435436
type FrameExtra = FrameData<'tcx>;
436437
type AllocExtra = AllocExtra;
438+
437439
type PointerTag = Tag;
438-
type ExtraFnVal = Dlsym;
440+
type TagExtra = SbTag;
439441

440442
type MemoryMap =
441443
MonoHashMap<AllocId, (MemoryKind<MiriMemoryKind>, Allocation<Tag, Self::AllocExtra>)>;
@@ -607,26 +609,26 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
607609
fn ptr_get_alloc(
608610
ecx: &MiriEvalContext<'mir, 'tcx>,
609611
ptr: Pointer<Self::PointerTag>,
610-
) -> (AllocId, Size) {
612+
) -> (AllocId, Size, Self::TagExtra) {
611613
let rel = intptrcast::GlobalStateInner::abs_ptr_to_rel(ecx, ptr);
612-
(ptr.provenance.alloc_id, rel)
614+
(ptr.provenance.alloc_id, rel, ptr.provenance.sb)
613615
}
614616

615617
#[inline(always)]
616618
fn memory_read(
617619
_tcx: TyCtxt<'tcx>,
618620
machine: &Self,
619621
alloc_extra: &AllocExtra,
620-
tag: Tag,
622+
(alloc_id, tag): (AllocId, Self::TagExtra),
621623
range: AllocRange,
622624
) -> InterpResult<'tcx> {
623625
if let Some(data_race) = &alloc_extra.data_race {
624-
data_race.read(tag.alloc_id, range, machine.data_race.as_ref().unwrap())?;
626+
data_race.read(alloc_id, range, machine.data_race.as_ref().unwrap())?;
625627
}
626628
if let Some(stacked_borrows) = &alloc_extra.stacked_borrows {
627629
stacked_borrows.memory_read(
628-
tag.alloc_id,
629-
tag.sb,
630+
alloc_id,
631+
tag,
630632
range,
631633
machine.stacked_borrows.as_ref().unwrap(),
632634
)
@@ -640,16 +642,16 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
640642
_tcx: TyCtxt<'tcx>,
641643
machine: &mut Self,
642644
alloc_extra: &mut AllocExtra,
643-
tag: Tag,
645+
(alloc_id, tag): (AllocId, Self::TagExtra),
644646
range: AllocRange,
645647
) -> InterpResult<'tcx> {
646648
if let Some(data_race) = &mut alloc_extra.data_race {
647-
data_race.write(tag.alloc_id, range, machine.data_race.as_mut().unwrap())?;
649+
data_race.write(alloc_id, range, machine.data_race.as_mut().unwrap())?;
648650
}
649651
if let Some(stacked_borrows) = &mut alloc_extra.stacked_borrows {
650652
stacked_borrows.memory_written(
651-
tag.alloc_id,
652-
tag.sb,
653+
alloc_id,
654+
tag,
653655
range,
654656
machine.stacked_borrows.as_mut().unwrap(),
655657
)
@@ -663,19 +665,19 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
663665
_tcx: TyCtxt<'tcx>,
664666
machine: &mut Self,
665667
alloc_extra: &mut AllocExtra,
666-
tag: Tag,
668+
(alloc_id, tag): (AllocId, Self::TagExtra),
667669
range: AllocRange,
668670
) -> InterpResult<'tcx> {
669-
if Some(tag.alloc_id) == machine.tracked_alloc_id {
670-
register_diagnostic(NonHaltingDiagnostic::FreedAlloc(tag.alloc_id));
671+
if Some(alloc_id) == machine.tracked_alloc_id {
672+
register_diagnostic(NonHaltingDiagnostic::FreedAlloc(alloc_id));
671673
}
672674
if let Some(data_race) = &mut alloc_extra.data_race {
673-
data_race.deallocate(tag.alloc_id, range, machine.data_race.as_mut().unwrap())?;
675+
data_race.deallocate(alloc_id, range, machine.data_race.as_mut().unwrap())?;
674676
}
675677
if let Some(stacked_borrows) = &mut alloc_extra.stacked_borrows {
676678
stacked_borrows.memory_deallocated(
677-
tag.alloc_id,
678-
tag.sb,
679+
alloc_id,
680+
tag,
679681
range,
680682
machine.stacked_borrows.as_mut().unwrap(),
681683
)

src/shims/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
124124

125125
let ptr = this.read_pointer(ptr)?;
126126
// Take apart the pointer, we need its pieces.
127-
let (alloc_id, offset, ptr) = this.ptr_get_alloc_id(ptr)?;
127+
let (alloc_id, offset, _tag) = this.ptr_get_alloc_id(ptr)?;
128128

129129
let fn_instance =
130130
if let Some(GlobalAlloc::Function(instance)) = this.tcx.get_global_alloc(alloc_id) {

src/stacked_borrows.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
702702
);
703703
return Ok(());
704704
}
705-
let (alloc_id, base_offset, ptr) = this.ptr_get_alloc_id(place.ptr)?;
706-
let orig_tag = ptr.provenance.sb;
705+
let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr)?;
707706

708707
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
709708
let (alloc_size, _) =

0 commit comments

Comments
 (0)