Skip to content

Commit

Permalink
remove the ability to disable ABI checking
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 2, 2024
1 parent 9272474 commit 6e4530c
Show file tree
Hide file tree
Showing 17 changed files with 11 additions and 128 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -359,8 +359,6 @@ The remaining flags are for advanced use only, and more likely to change or be r
Some of these are **unsound**, which means they can lead
to Miri failing to detect cases of undefined behavior in a program.

* `-Zmiri-disable-abi-check` disables checking [function ABI]. Using this flag
is **unsound**. This flag is **deprecated**.
* `-Zmiri-disable-alignment-check` disables checking pointer alignment, so you
can focus on other failures, but it means Miri can miss bugs in your program.
Using this flag is **unsound**.
Expand Down
5 changes: 2 additions & 3 deletions src/bin/miri.rs
Expand Up @@ -413,10 +413,9 @@ fn main() {
);
} else if arg == "-Zmiri-disable-abi-check" {
eprintln!(
"WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.\n\
If you have a use-case for it, please file an issue."
"WARNING: the flag `-Zmiri-disable-abi-check` no longer has any effect; \
ABI checks cannot be disabled any more"
);
miri_config.check_abi = false;
} else if arg == "-Zmiri-disable-isolation" {
if matches!(isolation_enabled, Some(true)) {
show_error!(
Expand Down
3 changes: 0 additions & 3 deletions src/eval.rs
Expand Up @@ -94,8 +94,6 @@ pub struct MiriConfig {
pub unique_is_unique: bool,
/// Controls alignment checking.
pub check_alignment: AlignmentCheck,
/// Controls function [ABI](Abi) checking.
pub check_abi: bool,
/// Action for an op requiring communication with the host.
pub isolated_op: IsolatedOp,
/// Determines if memory leaks should be ignored.
Expand Down Expand Up @@ -162,7 +160,6 @@ impl Default for MiriConfig {
borrow_tracker: Some(BorrowTrackerMethod::StackedBorrows),
unique_is_unique: false,
check_alignment: AlignmentCheck::Int,
check_abi: true,
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
ignore_leaks: false,
forwarded_env_vars: vec![],
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.rs
Expand Up @@ -387,7 +387,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let this = self.eval_context_mut();
let param_env = ty::ParamEnv::reveal_all(); // in Miri this is always the param_env we use... and this.param_env is private.
let callee_abi = f.ty(*this.tcx, param_env).fn_sig(*this.tcx).abi();
if this.machine.enforce_abi && callee_abi != caller_abi {
if callee_abi != caller_abi {
throw_ub_format!(
"calling a function with ABI {} using caller ABI {}",
callee_abi.name(),
Expand Down Expand Up @@ -945,7 +945,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

/// Check that the ABI is what we expect.
fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
if self.eval_context_ref().machine.enforce_abi && abi != exp_abi {
if abi != exp_abi {
throw_ub_format!(
"calling a function with ABI {} using caller ABI {}",
exp_abi.name(),
Expand Down
9 changes: 2 additions & 7 deletions src/machine.rs
Expand Up @@ -460,9 +460,6 @@ pub struct MiriMachine<'mir, 'tcx> {
/// Whether to enforce the validity invariant.
pub(crate) validate: bool,

/// Whether to enforce [ABI](Abi) of function calls.
pub(crate) enforce_abi: bool,

/// The table of file descriptors.
pub(crate) file_handler: shims::unix::FileHandler,
/// The table of directory descriptors.
Expand Down Expand Up @@ -641,7 +638,6 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
tls: TlsData::default(),
isolated_op: config.isolated_op,
validate: config.validate,
enforce_abi: config.check_abi,
file_handler: FileHandler::new(config.mute_stdout_stderr),
dir_handler: Default::default(),
layouts,
Expand Down Expand Up @@ -784,7 +780,6 @@ impl VisitProvenance for MiriMachine<'_, '_> {
tcx: _,
isolated_op: _,
validate: _,
enforce_abi: _,
clock: _,
layouts: _,
static_roots: _,
Expand Down Expand Up @@ -932,8 +927,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
}

#[inline(always)]
fn enforce_abi(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
ecx.machine.enforce_abi
fn enforce_abi(_ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
true
}

#[inline(always)]
Expand Down
29 changes: 0 additions & 29 deletions tests/fail-dep/concurrency/unwind_top_of_stack.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/fail-dep/concurrency/unwind_top_of_stack.stderr

This file was deleted.

1 change: 0 additions & 1 deletion tests/fail/function_calls/arg_inplace_mutate.rs
Expand Up @@ -19,7 +19,6 @@ fn main() {
after_call = {
Return()
}

}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/fail/function_calls/arg_inplace_mutate.stack.stderr
Expand Up @@ -14,7 +14,7 @@ LL | | let _unit: ();
LL | | {
LL | | let non_copy = S(42);
... |
LL | |
LL | | }
LL | | }
| |_____^
help: <TAG> is this argument
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/function_calls/arg_inplace_mutate.tree.stderr
Expand Up @@ -16,7 +16,7 @@ LL | | let _unit: ();
LL | | {
LL | | let non_copy = S(42);
... |
LL | |
LL | | }
LL | | }
| |_____^
help: the protected tag <TAG> was created here, in the initial state Reserved
Expand Down
1 change: 0 additions & 1 deletion tests/fail/function_calls/exported_symbol_bad_unwind1.rs
@@ -1,4 +1,3 @@
//@compile-flags: -Zmiri-disable-abi-check
#![feature(c_unwind)]

#[no_mangle]
Expand Down
2 changes: 0 additions & 2 deletions tests/fail/function_calls/exported_symbol_bad_unwind1.stderr
@@ -1,5 +1,3 @@
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
If you have a use-case for it, please file an issue.
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expand Down
12 changes: 0 additions & 12 deletions tests/fail/panic/bad_miri_start_unwind.rs

This file was deleted.

17 changes: 0 additions & 17 deletions tests/fail/panic/bad_miri_start_unwind.stderr

This file was deleted.

3 changes: 3 additions & 0 deletions tests/fail/panic/bad_unwind.rs
@@ -1,6 +1,9 @@
#![feature(c_unwind)]

//! Unwinding when the caller ABI is "C" (without "-unwind") is UB.
// The opposite version (callee does not allow unwinding) is impossible to
// even write: MIR validation catches functions that have `UnwindContinue` but
// are not allowed to unwind.

extern "C-unwind" fn unwind() {
panic!();
Expand Down
24 changes: 0 additions & 24 deletions tests/pass/function_calls/disable_abi_check.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/pass/function_calls/disable_abi_check.stderr

This file was deleted.

0 comments on commit 6e4530c

Please sign in to comment.