Skip to content

Commit 033c1e0

Browse files
committed
Auto merge of rust-lang#3340 - RalfJung:no-disable-abi-check, r=oli-obk
remove the ability to disable ABI checking This got deprecated in rust-lang/miri#3071, about half a year ago. `@rust-lang/miri` I think it's fine to remove this now.
2 parents e88704e + c1a5906 commit 033c1e0

17 files changed

+11
-128
lines changed

src/tools/miri/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ The remaining flags are for advanced use only, and more likely to change or be r
359359
Some of these are **unsound**, which means they can lead
360360
to Miri failing to detect cases of undefined behavior in a program.
361361

362-
* `-Zmiri-disable-abi-check` disables checking [function ABI]. Using this flag
363-
is **unsound**. This flag is **deprecated**.
364362
* `-Zmiri-disable-alignment-check` disables checking pointer alignment, so you
365363
can focus on other failures, but it means Miri can miss bugs in your program.
366364
Using this flag is **unsound**.

src/tools/miri/src/bin/miri.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,9 @@ fn main() {
407407
miri_config.check_alignment = miri::AlignmentCheck::Symbolic;
408408
} else if arg == "-Zmiri-disable-abi-check" {
409409
eprintln!(
410-
"WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.\n\
411-
If you have a use-case for it, please file an issue."
410+
"WARNING: the flag `-Zmiri-disable-abi-check` no longer has any effect; \
411+
ABI checks cannot be disabled any more"
412412
);
413-
miri_config.check_abi = false;
414413
} else if arg == "-Zmiri-disable-isolation" {
415414
if matches!(isolation_enabled, Some(true)) {
416415
show_error!(

src/tools/miri/src/eval.rs

-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ pub struct MiriConfig {
9494
pub unique_is_unique: bool,
9595
/// Controls alignment checking.
9696
pub check_alignment: AlignmentCheck,
97-
/// Controls function [ABI](Abi) checking.
98-
pub check_abi: bool,
9997
/// Action for an op requiring communication with the host.
10098
pub isolated_op: IsolatedOp,
10199
/// Determines if memory leaks should be ignored.
@@ -162,7 +160,6 @@ impl Default for MiriConfig {
162160
borrow_tracker: Some(BorrowTrackerMethod::StackedBorrows),
163161
unique_is_unique: false,
164162
check_alignment: AlignmentCheck::Int,
165-
check_abi: true,
166163
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
167164
ignore_leaks: false,
168165
forwarded_env_vars: vec![],

src/tools/miri/src/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
389389
let this = self.eval_context_mut();
390390
let param_env = ty::ParamEnv::reveal_all(); // in Miri this is always the param_env we use... and this.param_env is private.
391391
let callee_abi = f.ty(*this.tcx, param_env).fn_sig(*this.tcx).abi();
392-
if this.machine.enforce_abi && callee_abi != caller_abi {
392+
if callee_abi != caller_abi {
393393
throw_ub_format!(
394394
"calling a function with ABI {} using caller ABI {}",
395395
callee_abi.name(),
@@ -956,7 +956,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
956956

957957
/// Check that the ABI is what we expect.
958958
fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
959-
if self.eval_context_ref().machine.enforce_abi && abi != exp_abi {
959+
if abi != exp_abi {
960960
throw_ub_format!(
961961
"calling a function with ABI {} using caller ABI {}",
962962
exp_abi.name(),

src/tools/miri/src/machine.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,6 @@ pub struct MiriMachine<'mir, 'tcx> {
463463
/// Whether to enforce the validity invariant.
464464
pub(crate) validate: bool,
465465

466-
/// Whether to enforce [ABI](Abi) of function calls.
467-
pub(crate) enforce_abi: bool,
468-
469466
/// The table of file descriptors.
470467
pub(crate) file_handler: shims::unix::FileHandler,
471468
/// The table of directory descriptors.
@@ -644,7 +641,6 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
644641
tls: TlsData::default(),
645642
isolated_op: config.isolated_op,
646643
validate: config.validate,
647-
enforce_abi: config.check_abi,
648644
file_handler: FileHandler::new(config.mute_stdout_stderr),
649645
dir_handler: Default::default(),
650646
layouts,
@@ -787,7 +783,6 @@ impl VisitProvenance for MiriMachine<'_, '_> {
787783
tcx: _,
788784
isolated_op: _,
789785
validate: _,
790-
enforce_abi: _,
791786
clock: _,
792787
layouts: _,
793788
static_roots: _,
@@ -935,8 +930,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
935930
}
936931

937932
#[inline(always)]
938-
fn enforce_abi(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
939-
ecx.machine.enforce_abi
933+
fn enforce_abi(_ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
934+
true
940935
}
941936

942937
#[inline(always)]

src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs

-29
This file was deleted.

src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr

-21
This file was deleted.

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fn main() {
1919
after_call = {
2020
Return()
2121
}
22-
2322
}
2423
}
2524

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | | let _unit: ();
1414
LL | | {
1515
LL | | let non_copy = S(42);
1616
... |
17-
LL | |
17+
LL | | }
1818
LL | | }
1919
| |_____^
2020
help: <TAG> is this argument

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | let _unit: ();
1616
LL | | {
1717
LL | | let non_copy = S(42);
1818
... |
19-
LL | |
19+
LL | | }
2020
LL | | }
2121
| |_____^
2222
help: the protected tag <TAG> was created here, in the initial state Reserved

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@compile-flags: -Zmiri-disable-abi-check
21
#![feature(c_unwind)]
32

43
#[no_mangle]

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
2-
If you have a use-case for it, please file an issue.
31
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
42
explicit panic
53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs

-12
This file was deleted.

src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr

-17
This file was deleted.

src/tools/miri/tests/fail/panic/bad_unwind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![feature(c_unwind)]
22

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

58
extern "C-unwind" fn unwind() {
69
panic!();

src/tools/miri/tests/pass/function_calls/disable_abi_check.rs

-24
This file was deleted.

src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr

-2
This file was deleted.

0 commit comments

Comments
 (0)