about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-06 07:37:33 +0000
committerbors <bors@rust-lang.org>2024-03-06 07:37:33 +0000
commit033c1e00b0fda6616c1442ecf40bb79da8c5db20 (patch)
treee5e81e03e90da78fd619763a95ef4ac47ec25f94
parente88704e48ca60436797a689f7cdaded55678c0d4 (diff)
parentc1a5906d54730b156061542f9c6bfc4f187f4105 (diff)
downloadrust-033c1e00b0fda6616c1442ecf40bb79da8c5db20.tar.gz
rust-033c1e00b0fda6616c1442ecf40bb79da8c5db20.zip
Auto merge of #3340 - RalfJung:no-disable-abi-check, r=oli-obk
remove the ability to disable ABI checking

This got deprecated in https://github.com/rust-lang/miri/pull/3071, about half a year ago.

`@rust-lang/miri` I think it's fine to remove this now.
-rw-r--r--src/tools/miri/README.md2
-rw-r--r--src/tools/miri/src/bin/miri.rs5
-rw-r--r--src/tools/miri/src/eval.rs3
-rw-r--r--src/tools/miri/src/helpers.rs4
-rw-r--r--src/tools/miri/src/machine.rs9
-rw-r--r--src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs29
-rw-r--r--src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr21
-rw-r--r--src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs1
-rw-r--r--src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr2
-rw-r--r--src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr2
-rw-r--r--src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs1
-rw-r--r--src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr2
-rw-r--r--src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs12
-rw-r--r--src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr17
-rw-r--r--src/tools/miri/tests/fail/panic/bad_unwind.rs3
-rw-r--r--src/tools/miri/tests/pass/function_calls/disable_abi_check.rs24
-rw-r--r--src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr2
17 files changed, 11 insertions, 128 deletions
diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md
index 372e00f8542..b043805291e 100644
--- a/src/tools/miri/README.md
+++ b/src/tools/miri/README.md
@@ -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**.
diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs
index 69ea9e5fad9..22108df0f26 100644
--- a/src/tools/miri/src/bin/miri.rs
+++ b/src/tools/miri/src/bin/miri.rs
@@ -407,10 +407,9 @@ fn main() {
             miri_config.check_alignment = miri::AlignmentCheck::Symbolic;
         } 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!(
diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs
index ef50bd43de3..4e080f0cc3b 100644
--- a/src/tools/miri/src/eval.rs
+++ b/src/tools/miri/src/eval.rs
@@ -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.
@@ -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![],
diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs
index c3f4deb7c2e..d69c6fe9012 100644
--- a/src/tools/miri/src/helpers.rs
+++ b/src/tools/miri/src/helpers.rs
@@ -389,7 +389,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(),
@@ -956,7 +956,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(),
diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs
index f0e851c132f..f226354200f 100644
--- a/src/tools/miri/src/machine.rs
+++ b/src/tools/miri/src/machine.rs
@@ -463,9 +463,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.
@@ -644,7 +641,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,
@@ -787,7 +783,6 @@ impl VisitProvenance for MiriMachine<'_, '_> {
             tcx: _,
             isolated_op: _,
             validate: _,
-            enforce_abi: _,
             clock: _,
             layouts: _,
             static_roots: _,
@@ -935,8 +930,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)]
diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs
deleted file mode 100644
index 4704cfed039..00000000000
--- a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-//@ignore-target-windows: No libc on Windows
-
-//@compile-flags: -Zmiri-disable-abi-check
-
-//! Unwinding past the top frame of a stack is Undefined Behavior.
-
-#![feature(c_unwind)]
-
-use std::{mem, ptr};
-
-extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
-    //~^ ERROR: unwinding past the topmost frame of the stack
-    panic!()
-}
-
-fn main() {
-    unsafe {
-        let mut native: libc::pthread_t = mem::zeroed();
-        let attr: libc::pthread_attr_t = mem::zeroed();
-        // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented.
-        // Cast to avoid inserting abort-on-unwind.
-        let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void =
-            thread_start;
-        let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void =
-            mem::transmute(thread_start);
-        assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0);
-        assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
-    }
-}
diff --git a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr b/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr
deleted file mode 100644
index 0c755215c00..00000000000
--- a/src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-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 '<unnamed>' panicked at $DIR/unwind_top_of_stack.rs:LL:CC:
-explicit panic
-note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
-error: Undefined Behavior: unwinding past the topmost frame of the stack
-  --> $DIR/unwind_top_of_stack.rs:LL:CC
-   |
-LL | / extern "C-unwind" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void {
-LL | |
-LL | |     panic!()
-LL | | }
-   | |_^ unwinding past the topmost frame of the stack
-   |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
-   = note: BACKTRACE on thread `unnamed-ID`:
-   = note: inside `thread_start` at $DIR/unwind_top_of_stack.rs:LL:CC
-
-error: aborting due to 1 previous error
-
diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs
index 8a5c10913b4..4f7a12ebd2e 100644
--- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs
+++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs
@@ -19,7 +19,6 @@ fn main() {
         after_call = {
             Return()
         }
-
     }
 }
 
diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr
index 422dc243436..e0d1bed6332 100644
--- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr
+++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr
@@ -14,7 +14,7 @@ LL | |         let _unit: ();
 LL | |         {
 LL | |             let non_copy = S(42);
 ...  |
-LL | |
+LL | |         }
 LL | |     }
    | |_____^
 help: <TAG> is this argument
diff --git a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr
index 354631bdcb5..c187d24e5e8 100644
--- a/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr
+++ b/src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr
@@ -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
diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs
index 5f4df7c6a1e..6d68b9a46d9 100644
--- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs
+++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs
@@ -1,4 +1,3 @@
-//@compile-flags: -Zmiri-disable-abi-check
 #![feature(c_unwind)]
 
 #[no_mangle]
diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr
index c5ca1274574..ab32883a035 100644
--- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr
+++ b/src/tools/miri/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
diff --git a/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs
deleted file mode 100644
index deca836a36c..00000000000
--- a/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-//@compile-flags: -Zmiri-disable-abi-check
-// This feature is required to trigger the error using the "C" ABI.
-#![feature(c_unwind)]
-
-extern "C" {
-    fn miri_start_unwind(payload: *mut u8) -> !;
-}
-
-fn main() {
-    unsafe { miri_start_unwind(&mut 0) }
-    //~^ ERROR: unwinding past a stack frame that does not allow unwinding
-}
diff --git a/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr
deleted file mode 100644
index 6c85aac050a..00000000000
--- a/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-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.
-error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding
-  --> $DIR/bad_miri_start_unwind.rs:LL:CC
-   |
-LL |     unsafe { miri_start_unwind(&mut 0) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding
-   |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
-   = note: BACKTRACE:
-   = note: inside `main` at $DIR/bad_miri_start_unwind.rs:LL:CC
-
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
-error: aborting due to 1 previous error
-
diff --git a/src/tools/miri/tests/fail/panic/bad_unwind.rs b/src/tools/miri/tests/fail/panic/bad_unwind.rs
index 370b372a7d3..8c8a9f18cdc 100644
--- a/src/tools/miri/tests/fail/panic/bad_unwind.rs
+++ b/src/tools/miri/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!();
diff --git a/src/tools/miri/tests/pass/function_calls/disable_abi_check.rs b/src/tools/miri/tests/pass/function_calls/disable_abi_check.rs
deleted file mode 100644
index 0f41047c603..00000000000
--- a/src/tools/miri/tests/pass/function_calls/disable_abi_check.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-//@compile-flags: -Zmiri-disable-abi-check
-#![feature(core_intrinsics)]
-
-fn main() {
-    fn foo() {}
-
-    extern "C" fn try_fn(ptr: *mut u8) {
-        assert!(ptr.is_null());
-    }
-
-    extern "Rust" {
-        fn malloc(size: usize) -> *mut std::ffi::c_void;
-    }
-
-    unsafe {
-        let _ = malloc(0);
-        std::mem::transmute::<fn(), extern "C" fn()>(foo)();
-        std::intrinsics::catch_unwind(
-            std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
-            std::ptr::null_mut(),
-            |_, _| unreachable!(),
-        );
-    }
-}
diff --git a/src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr b/src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr
deleted file mode 100644
index e5b84f6d709..00000000000
--- a/src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr
+++ /dev/null
@@ -1,2 +0,0 @@
-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.