Skip to content

Commit bdc100f

Browse files
committed
Auto merge of #3950 - RalfJung:handle_unsupported_foreign_item, r=RalfJung,saethlin,oli-obk
remove -Zmiri-panic-on-unsupported flag Fixes #3952, see that issue for discussion.
2 parents a79012b + 2b3deec commit bdc100f

11 files changed

+3
-69
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,6 @@ to Miri failing to detect cases of undefined behavior in a program.
392392
but reports to the program that it did actually write. This is useful when you
393393
are not interested in the actual program's output, but only want to see Miri's
394394
errors and warnings.
395-
* `-Zmiri-panic-on-unsupported` will make some forms of unsupported functionality,
396-
such as FFI and unsupported syscalls, panic within the context of the emulated
397-
application instead of raising an error within the context of Miri (and halting
398-
execution). Note that code might not expect these operations to ever panic, so
399-
this flag can lead to strange (mis)behavior.
400395
* `-Zmiri-recursive-validation` is a *highly experimental* flag that makes validity checking
401396
recurse below references.
402397
* `-Zmiri-retag-fields[=<all|none|scalar>]` controls when Stacked Borrows retagging recurses into

src/bin/miri.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ fn main() {
530530
} else if arg == "-Zmiri-ignore-leaks" {
531531
miri_config.ignore_leaks = true;
532532
miri_config.collect_leak_backtraces = false;
533-
} else if arg == "-Zmiri-panic-on-unsupported" {
534-
miri_config.panic_on_unsupported = true;
535533
} else if arg == "-Zmiri-strict-provenance" {
536534
miri_config.provenance_mode = ProvenanceMode::Strict;
537535
} else if arg == "-Zmiri-permissive-provenance" {

src/eval.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ pub struct MiriConfig {
129129
/// If `Some`, enable the `measureme` profiler, writing results to a file
130130
/// with the specified prefix.
131131
pub measureme_out: Option<String>,
132-
/// Panic when unsupported functionality is encountered.
133-
pub panic_on_unsupported: bool,
134132
/// Which style to use for printing backtraces.
135133
pub backtrace_style: BacktraceStyle,
136134
/// Which provenance to use for int2ptr casts
@@ -183,7 +181,6 @@ impl Default for MiriConfig {
183181
track_outdated_loads: false,
184182
cmpxchg_weak_failure_rate: 0.8, // 80%
185183
measureme_out: None,
186-
panic_on_unsupported: false,
187184
backtrace_style: BacktraceStyle::Short,
188185
provenance_mode: ProvenanceMode::Default,
189186
mute_stdout_stderr: false,

src/helpers.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc_index::IndexVec;
1414
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1515
use rustc_middle::middle::dependency_format::Linkage;
1616
use rustc_middle::middle::exported_symbols::ExportedSymbol;
17-
use rustc_middle::mir;
1817
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
1918
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
2019
use rustc_session::config::CrateType;
@@ -949,21 +948,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
949948
crate_name == "std" || crate_name == "std_miri_test"
950949
}
951950

952-
/// Handler that should be called when an unsupported foreign item is encountered.
953-
/// This function will either panic within the context of the emulated application
954-
/// or return an error in the Miri process context
955-
fn handle_unsupported_foreign_item(&mut self, error_msg: String) -> InterpResult<'tcx, ()> {
956-
let this = self.eval_context_mut();
957-
if this.machine.panic_on_unsupported {
958-
// message is slightly different here to make automated analysis easier
959-
let error_msg = format!("unsupported Miri functionality: {error_msg}");
960-
this.start_panic(error_msg.as_ref(), mir::UnwindAction::Continue)?;
961-
interp_ok(())
962-
} else {
963-
throw_machine_stop!(TerminationInfo::UnsupportedForeignItem(error_msg));
964-
}
965-
}
966-
967951
fn check_abi_and_shim_symbol_clash(
968952
&mut self,
969953
abi: Abi,

src/machine.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,6 @@ pub struct MiriMachine<'tcx> {
496496
/// `None` means no `Instance` exported under the given name is found.
497497
pub(crate) exported_symbols_cache: FxHashMap<Symbol, Option<Instance<'tcx>>>,
498498

499-
/// Whether to raise a panic in the context of the evaluated process when unsupported
500-
/// functionality is encountered. If `false`, an error is propagated in the Miri application context
501-
/// instead (default behavior)
502-
pub(crate) panic_on_unsupported: bool,
503-
504499
/// Equivalent setting as RUST_BACKTRACE on encountering an error.
505500
pub(crate) backtrace_style: BacktraceStyle,
506501

@@ -667,7 +662,6 @@ impl<'tcx> MiriMachine<'tcx> {
667662
profiler,
668663
string_cache: Default::default(),
669664
exported_symbols_cache: FxHashMap::default(),
670-
panic_on_unsupported: config.panic_on_unsupported,
671665
backtrace_style: config.backtrace_style,
672666
local_crates,
673667
extern_statics: FxHashMap::default(),
@@ -807,7 +801,6 @@ impl VisitProvenance for MiriMachine<'_> {
807801
profiler: _,
808802
string_cache: _,
809803
exported_symbols_cache: _,
810-
panic_on_unsupported: _,
811804
backtrace_style: _,
812805
local_crates: _,
813806
rng: _,

src/shims/foreign_items.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8383
return interp_ok(Some(body));
8484
}
8585

86-
this.handle_unsupported_foreign_item(format!(
86+
throw_machine_stop!(TerminationInfo::UnsupportedForeignItem(format!(
8787
"can't call foreign function `{link_name}` on OS `{os}`",
8888
os = this.tcx.sess.target.os,
89-
))?;
90-
return interp_ok(None);
89+
)));
9190
}
9291
}
9392

src/shims/unix/linux/foreign_items.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
168168
this.write_int(result.to_i32()?, dest)?;
169169
}
170170
id => {
171-
this.handle_unsupported_foreign_item(format!(
172-
"can't execute syscall with ID {id}"
173-
))?;
174-
return interp_ok(EmulateItemResult::AlreadyJumped);
171+
throw_unsup_format!("can't execute syscall with ID {id}");
175172
}
176173
}
177174
}

tests/panic/unsupported_foreign_function.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/panic/unsupported_foreign_function.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/panic/unsupported_syscall.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/panic/unsupported_syscall.stderr

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)