Skip to content

Commit 15476b9

Browse files
committed
panic when an interpreter error gets unintentionally discarded
1 parent 0cb4d98 commit 15476b9

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/concurrency/data_race.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ pub trait EvalContextExt<'tcx>: MiriInterpCxExt<'tcx> {
641641
// The program didn't actually do a read, so suppress the memory access hooks.
642642
// This is also a very special exception where we just ignore an error -- if this read
643643
// was UB e.g. because the memory is uninitialized, we don't want to know!
644-
let old_val = this.run_for_validation(|this| this.read_scalar(dest)).ok();
644+
let old_val = this.run_for_validation(|this| this.read_scalar(dest)).discard_interp_err();
645645
this.allow_data_races_mut(move |this| this.write_scalar(val, dest))?;
646646
this.validate_atomic_store(dest, atomic)?;
647647
this.buffered_atomic_write(val, dest, atomic, old_val)

src/diagnostics.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ pub fn report_error<'tcx>(
223223
let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
224224
use TerminationInfo::*;
225225
let title = match info {
226-
Exit { code, leak_check } => return Some((*code, *leak_check)),
226+
&Exit { code, leak_check } => {
227+
e.discard_interp_err();
228+
return Some((code, leak_check));
229+
}
227230
Abort(_) => Some("abnormal termination"),
228231
UnsupportedInIsolation(_) | Int2PtrWithStrictProvenance | UnsupportedForeignItem(_) =>
229232
Some("unsupported operation"),
@@ -375,6 +378,7 @@ pub fn report_error<'tcx>(
375378
InvalidProgramInfo::AlreadyReported(_)
376379
) => {
377380
// This got already reported. No point in reporting it again.
381+
e.discard_interp_err();
378382
return None;
379383
}
380384
_ =>

src/intrinsics/simd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
247247
// This does NaN adjustments.
248248
let val = this.binary_op(mir_op, &left, &right).map_err(|err| {
249249
match err.kind() {
250-
InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ShiftOverflow { shift_amount, .. }) => {
250+
&InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ShiftOverflow { shift_amount, .. }) => {
251+
err.discard_interp_err();
251252
// This resets the interpreter backtrace, but it's not worth avoiding that.
252253
let shift_amount = match shift_amount {
253254
Either::Left(v) => v.to_string(),

0 commit comments

Comments
 (0)