fix ICE in pointer tracking
This commit is contained in:
parent
90118a197b
commit
0d1e365272
@ -455,23 +455,18 @@ impl<'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'history, 'ecx, 'mir, 'tcx> {
|
|||||||
if !global.tracked_pointer_tags.contains(&item.tag()) {
|
if !global.tracked_pointer_tags.contains(&item.tag()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let summary = match self.operation {
|
let cause = match self.operation {
|
||||||
Operation::Dealloc(_) => None,
|
Operation::Dealloc(_) => format!(" due to deallocation"),
|
||||||
Operation::Access(AccessOp { kind, tag, .. }) => Some((tag, kind)),
|
Operation::Access(AccessOp { kind, tag, .. }) =>
|
||||||
|
format!(" due to {kind:?} access for {tag:?}"),
|
||||||
Operation::Retag(RetagOp { orig_tag, permission, .. }) => {
|
Operation::Retag(RetagOp { orig_tag, permission, .. }) => {
|
||||||
let kind = match permission
|
let permission = permission
|
||||||
.expect("start_grant should set the current permission before popping a tag")
|
.expect("start_grant should set the current permission before popping a tag");
|
||||||
{
|
format!(" due to {permission:?} retag from {orig_tag:?}")
|
||||||
Permission::SharedReadOnly => AccessKind::Read,
|
|
||||||
Permission::Unique => AccessKind::Write,
|
|
||||||
Permission::SharedReadWrite | Permission::Disabled => {
|
|
||||||
panic!("Only SharedReadOnly and Unique retags can pop tags");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Some((orig_tag, kind))
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.machine.emit_diagnostic(NonHaltingDiagnostic::PoppedPointerTag(*item, summary));
|
|
||||||
|
self.machine.emit_diagnostic(NonHaltingDiagnostic::PoppedPointerTag(*item, cause));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use log::trace;
|
|||||||
use rustc_span::{source_map::DUMMY_SP, SpanData, Symbol};
|
use rustc_span::{source_map::DUMMY_SP, SpanData, Symbol};
|
||||||
use rustc_target::abi::{Align, Size};
|
use rustc_target::abi::{Align, Size};
|
||||||
|
|
||||||
use crate::borrow_tracker::{stacked_borrows::diagnostics::TagHistory, AccessKind};
|
use crate::borrow_tracker::stacked_borrows::diagnostics::TagHistory;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
/// Details of premature program termination.
|
/// Details of premature program termination.
|
||||||
@ -67,9 +67,8 @@ pub enum NonHaltingDiagnostic {
|
|||||||
///
|
///
|
||||||
/// new_kind is `None` for base tags.
|
/// new_kind is `None` for base tags.
|
||||||
CreatedPointerTag(NonZeroU64, Option<String>, Option<(AllocId, AllocRange, ProvenanceExtra)>),
|
CreatedPointerTag(NonZeroU64, Option<String>, Option<(AllocId, AllocRange, ProvenanceExtra)>),
|
||||||
/// This `Item` was popped from the borrow stack, either due to an access with the given tag or
|
/// This `Item` was popped from the borrow stack. The string explains the reason.
|
||||||
/// a deallocation when the second argument is `None`.
|
PoppedPointerTag(Item, String),
|
||||||
PoppedPointerTag(Item, Option<(ProvenanceExtra, AccessKind)>),
|
|
||||||
CreatedCallId(CallId),
|
CreatedCallId(CallId),
|
||||||
CreatedAlloc(AllocId, Size, Align, MemoryKind<MiriMemoryKind>),
|
CreatedAlloc(AllocId, Size, Align, MemoryKind<MiriMemoryKind>),
|
||||||
FreedAlloc(AllocId),
|
FreedAlloc(AllocId),
|
||||||
@ -399,15 +398,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
|
|||||||
format!(
|
format!(
|
||||||
"created tag {tag:?} for {kind} at {alloc_id:?}{range:?} derived from {orig_tag:?}"
|
"created tag {tag:?} for {kind} at {alloc_id:?}{range:?} derived from {orig_tag:?}"
|
||||||
),
|
),
|
||||||
PoppedPointerTag(item, tag) =>
|
PoppedPointerTag(item, cause) => format!("popped tracked tag for item {item:?}{cause}"),
|
||||||
match tag {
|
|
||||||
None => format!("popped tracked tag for item {item:?} due to deallocation",),
|
|
||||||
Some((tag, access)) => {
|
|
||||||
format!(
|
|
||||||
"popped tracked tag for item {item:?} due to {access:?} access for {tag:?}",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
CreatedCallId(id) => format!("function call with id {id}"),
|
CreatedCallId(id) => format!("function call with id {id}"),
|
||||||
CreatedAlloc(AllocId(id), size, align, kind) =>
|
CreatedAlloc(AllocId(id), size, align, kind) =>
|
||||||
format!(
|
format!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user