adjust for provenance cleanup
This commit is contained in:
parent
598ae7418b
commit
ec1dc749a3
4 changed files with 24 additions and 23 deletions
|
|
@ -999,7 +999,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
|
|||
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 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
|
|||
"Atomic op({}) with ordering {:?} on {:?} (size={})",
|
||||
description,
|
||||
&atomic,
|
||||
ptr,
|
||||
place.ptr,
|
||||
size.bytes()
|
||||
);
|
||||
|
||||
|
|
@ -1039,7 +1039,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
|
|||
{
|
||||
log::trace!(
|
||||
"Updated atomic memory({:?}, size={}) to {:#?}",
|
||||
ptr,
|
||||
place.ptr,
|
||||
size.bytes(),
|
||||
range.atomic_ops
|
||||
);
|
||||
|
|
|
|||
|
|
@ -431,11 +431,13 @@ impl<'mir, 'tcx> MiriEvalContextExt<'mir, 'tcx> for 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 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
|
|||
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 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
|
|||
_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 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
|
|||
_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 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
|
|||
_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(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -702,8 +702,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
);
|
||||
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, _) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue