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.
This commit is contained in:
commit
033c1e00b0
17 changed files with 11 additions and 128 deletions
|
|
@ -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**.
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
|
|
|
|||
|
|
@ -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![],
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -19,7 +19,6 @@ fn main() {
|
|||
after_call = {
|
||||
Return()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ LL | | let _unit: ();
|
|||
LL | | {
|
||||
LL | | let non_copy = S(42);
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^
|
||||
help: <TAG> is this argument
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
//@compile-flags: -Zmiri-disable-abi-check
|
||||
#![feature(c_unwind)]
|
||||
|
||||
#[no_mangle]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
|
|
@ -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!();
|
||||
|
|
|
|||
|
|
@ -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!(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue