interpret: ensure that Place is never used for a different frame
This commit is contained in:
parent
1678c5c328
commit
2005c2e54d
4 changed files with 46 additions and 33 deletions
|
@ -1,4 +1,5 @@
|
|||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
use std::{fmt, mem};
|
||||
|
||||
use either::{Either, Left, Right};
|
||||
|
@ -279,6 +280,11 @@ impl<'mir, 'tcx, Prov: Provenance, Extra> Frame<'mir, 'tcx, Prov, Extra> {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(super) fn locals_addr(&self) -> usize {
|
||||
ptr::addr_of!(self.locals).addr()
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: only used by miri, should be removed once translatable.
|
||||
|
@ -1212,18 +1218,16 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> std::fmt::Debug
|
|||
{
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self.place {
|
||||
Place::Local { frame, local, offset } => {
|
||||
Place::Local { local, offset, locals_addr } => {
|
||||
debug_assert_eq!(locals_addr, self.ecx.frame().locals_addr());
|
||||
let mut allocs = Vec::new();
|
||||
write!(fmt, "{local:?}")?;
|
||||
if let Some(offset) = offset {
|
||||
write!(fmt, "+{:#x}", offset.bytes())?;
|
||||
}
|
||||
if frame != self.ecx.frame_idx() {
|
||||
write!(fmt, " ({} frames up)", self.ecx.frame_idx() - frame)?;
|
||||
}
|
||||
write!(fmt, ":")?;
|
||||
|
||||
match self.ecx.stack()[frame].locals[local].value {
|
||||
match self.ecx.frame().locals[local].value {
|
||||
LocalValue::Dead => write!(fmt, " is dead")?,
|
||||
LocalValue::Live(Operand::Immediate(Immediate::Uninit)) => {
|
||||
write!(fmt, " is uninitialized")?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue