Emit errors without halting interpretation
This commit is contained in:
parent
4411903cca
commit
96d6efdf32
3 changed files with 23 additions and 12 deletions
|
|
@ -70,10 +70,14 @@ pub fn register_err(e: InterpErrorInfo<'static>) {
|
|||
ECX.with(|ecx| ecx.borrow_mut().push(e));
|
||||
}
|
||||
|
||||
pub fn process_errors(mut f: impl FnMut(InterpErrorInfo<'static>)) {
|
||||
ECX.with(|ecx| {
|
||||
for e in ecx.borrow_mut().drain(..) {
|
||||
f(e);
|
||||
}
|
||||
});
|
||||
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
|
||||
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
|
||||
fn process_errors(&self) {
|
||||
let this = self.eval_context_ref();
|
||||
ECX.with(|ecx| {
|
||||
for e in ecx.borrow_mut().drain(..) {
|
||||
report_err(this, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@ pub use crate::shims::time::EvalContextExt as TimeEvalContextExt;
|
|||
pub use crate::shims::tls::{EvalContextExt as TlsEvalContextExt, TlsData};
|
||||
pub use crate::shims::EvalContextExt as ShimsEvalContextExt;
|
||||
|
||||
pub use crate::diagnostics::{process_errors, register_err, report_err};
|
||||
pub use crate::diagnostics::{
|
||||
register_err, report_err, EvalContextExt as DiagnosticsEvalContextExt,
|
||||
};
|
||||
pub use crate::eval::{create_ecx, eval_main, MiriConfig, TerminationInfo};
|
||||
pub use crate::helpers::EvalContextExt as HelpersEvalContextExt;
|
||||
pub use crate::machine::{
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ use std::rc::Rc;
|
|||
use rustc_hir::Mutability;
|
||||
use rustc::mir::RetagKind;
|
||||
use rustc::ty::{self, layout::Size};
|
||||
use rustc_mir::interpret::InterpError;
|
||||
|
||||
use crate::{
|
||||
AllocId, HelpersEvalContextExt, ImmTy, Immediate, InterpResult, MPlaceTy, MemoryKind,
|
||||
MiriMemoryKind, PlaceTy, Pointer, RangeMap, TerminationInfo,
|
||||
};
|
||||
use crate::*;
|
||||
|
||||
pub type PtrId = NonZeroU64;
|
||||
pub type CallId = NonZeroU64;
|
||||
|
|
@ -269,7 +267,12 @@ impl<'tcx> Stack {
|
|||
fn check_protector(item: &Item, tag: Option<Tag>, global: &GlobalState) -> InterpResult<'tcx> {
|
||||
if let Tag::Tagged(id) = item.tag {
|
||||
if Some(id) == global.tracked_pointer_tag {
|
||||
throw_machine_stop!(TerminationInfo::PoppedTrackedPointerTag(item.clone()));
|
||||
register_err(
|
||||
InterpError::MachineStop(Box::new(TerminationInfo::PoppedTrackedPointerTag(
|
||||
item.clone(),
|
||||
)))
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(call) = item.protector {
|
||||
|
|
@ -630,6 +633,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
|||
this.write_immediate(val, place)?;
|
||||
}
|
||||
|
||||
this.process_errors();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue