adjust for provenance cleanup

This commit is contained in:
Ralf Jung
2022-04-18 10:20:11 -04:00
parent 598ae7418b
commit ec1dc749a3
4 changed files with 24 additions and 23 deletions
+3 -3
View File
@@ -999,7 +999,7 @@ fn validate_atomic_op<A: Debug + Copy>(
if let Some(data_race) = &this.machine.data_race {
if data_race.multi_threaded.get() {
let size = place.layout.size;
let (alloc_id, base_offset, ptr) = this.ptr_get_alloc_id(place.ptr)?;
let (alloc_id, base_offset, _tag) = this.ptr_get_alloc_id(place.ptr)?;
// Load and log the atomic operation.
// Note that atomic loads are possible even from read-only allocations, so `get_alloc_extra_mut` is not an option.
let alloc_meta = &this.get_alloc_extra(alloc_id)?.data_race.as_ref().unwrap();
@@ -1007,7 +1007,7 @@ fn validate_atomic_op<A: Debug + Copy>(
"Atomic op({}) with ordering {:?} on {:?} (size={})",
description,
&atomic,
ptr,
place.ptr,
size.bytes()
);
@@ -1039,7 +1039,7 @@ fn validate_atomic_op<A: Debug + Copy>(
{
log::trace!(
"Updated atomic memory({:?}, size={}) to {:#?}",
ptr,
place.ptr,
size.bytes(),
range.atomic_ops
);
+19 -17
View File
@@ -431,11 +431,13 @@ fn eval_context_mut(&mut self) -> &mut MiriEvalContext<'mir, 'tcx> {
/// Machine hook implementations.
impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
type MemoryKind = MiriMemoryKind;
type ExtraFnVal = Dlsym;
type FrameExtra = FrameData<'tcx>;
type AllocExtra = AllocExtra;
type PointerTag = Tag;
type ExtraFnVal = Dlsym;
type TagExtra = SbTag;
type MemoryMap =
MonoHashMap<AllocId, (MemoryKind<MiriMemoryKind>, Allocation<Tag, Self::AllocExtra>)>;
@@ -607,9 +609,9 @@ fn ptr_from_addr(
fn ptr_get_alloc(
ecx: &MiriEvalContext<'mir, 'tcx>,
ptr: Pointer<Self::PointerTag>,
) -> (AllocId, Size) {
) -> (AllocId, Size, Self::TagExtra) {
let rel = intptrcast::GlobalStateInner::abs_ptr_to_rel(ecx, ptr);
(ptr.provenance.alloc_id, rel)
(ptr.provenance.alloc_id, rel, ptr.provenance.sb)
}
#[inline(always)]
@@ -617,16 +619,16 @@ fn memory_read(
_tcx: TyCtxt<'tcx>,
machine: &Self,
alloc_extra: &AllocExtra,
tag: Tag,
(alloc_id, tag): (AllocId, Self::TagExtra),
range: AllocRange,
) -> InterpResult<'tcx> {
if let Some(data_race) = &alloc_extra.data_race {
data_race.read(tag.alloc_id, range, machine.data_race.as_ref().unwrap())?;
data_race.read(alloc_id, range, machine.data_race.as_ref().unwrap())?;
}
if let Some(stacked_borrows) = &alloc_extra.stacked_borrows {
stacked_borrows.memory_read(
tag.alloc_id,
tag.sb,
alloc_id,
tag,
range,
machine.stacked_borrows.as_ref().unwrap(),
)
@@ -640,16 +642,16 @@ fn memory_written(
_tcx: TyCtxt<'tcx>,
machine: &mut Self,
alloc_extra: &mut AllocExtra,
tag: Tag,
(alloc_id, tag): (AllocId, Self::TagExtra),
range: AllocRange,
) -> InterpResult<'tcx> {
if let Some(data_race) = &mut alloc_extra.data_race {
data_race.write(tag.alloc_id, range, machine.data_race.as_mut().unwrap())?;
data_race.write(alloc_id, range, machine.data_race.as_mut().unwrap())?;
}
if let Some(stacked_borrows) = &mut alloc_extra.stacked_borrows {
stacked_borrows.memory_written(
tag.alloc_id,
tag.sb,
alloc_id,
tag,
range,
machine.stacked_borrows.as_mut().unwrap(),
)
@@ -663,19 +665,19 @@ fn memory_deallocated(
_tcx: TyCtxt<'tcx>,
machine: &mut Self,
alloc_extra: &mut AllocExtra,
tag: Tag,
(alloc_id, tag): (AllocId, Self::TagExtra),
range: AllocRange,
) -> InterpResult<'tcx> {
if Some(tag.alloc_id) == machine.tracked_alloc_id {
register_diagnostic(NonHaltingDiagnostic::FreedAlloc(tag.alloc_id));
if Some(alloc_id) == machine.tracked_alloc_id {
register_diagnostic(NonHaltingDiagnostic::FreedAlloc(alloc_id));
}
if let Some(data_race) = &mut alloc_extra.data_race {
data_race.deallocate(tag.alloc_id, range, machine.data_race.as_mut().unwrap())?;
data_race.deallocate(alloc_id, range, machine.data_race.as_mut().unwrap())?;
}
if let Some(stacked_borrows) = &mut alloc_extra.stacked_borrows {
stacked_borrows.memory_deallocated(
tag.alloc_id,
tag.sb,
alloc_id,
tag,
range,
machine.stacked_borrows.as_mut().unwrap(),
)
+1 -1
View File
@@ -124,7 +124,7 @@ fn resolve_frame_pointer(
let ptr = this.read_pointer(ptr)?;
// Take apart the pointer, we need its pieces.
let (alloc_id, offset, ptr) = this.ptr_get_alloc_id(ptr)?;
let (alloc_id, offset, _tag) = this.ptr_get_alloc_id(ptr)?;
let fn_instance =
if let Some(GlobalAlloc::Function(instance)) = this.tcx.get_global_alloc(alloc_id) {
+1 -2
View File
@@ -702,8 +702,7 @@ fn reborrow(
);
return Ok(());
}
let (alloc_id, base_offset, ptr) = this.ptr_get_alloc_id(place.ptr)?;
let orig_tag = ptr.provenance.sb;
let (alloc_id, base_offset, orig_tag) = this.ptr_get_alloc_id(place.ptr)?;
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
let (alloc_size, _) =