From 5ec97e508e78e96574cffd498d7252897c22785d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 25 Feb 2024 18:54:41 +0100 Subject: [PATCH] =?UTF-8?q?miri:=20rename=20miri=5Fstart=5Fpanic=20?= =?UTF-8?q?=E2=86=92=20miri=5Fstart=5Funwind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/panic_unwind/src/miri.rs | 6 +++--- src/tools/miri/src/concurrency/thread.rs | 2 +- src/tools/miri/src/shims/foreign_items.rs | 6 +++--- src/tools/miri/src/shims/panic.rs | 14 +++++++------- ...iri_start_panic.rs => bad_miri_start_unwind.rs} | 4 ++-- ...t_panic.stderr => bad_miri_start_unwind.stderr} | 8 ++++---- .../miri/tests/fail/panic/unwind_panic_abort.rs | 4 ++-- .../tests/fail/panic/unwind_panic_abort.stderr | 4 ++-- src/tools/miri/tests/utils/miri_extern.rs | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) rename src/tools/miri/tests/fail/panic/{bad_miri_start_panic.rs => bad_miri_start_unwind.rs} (72%) rename src/tools/miri/tests/fail/panic/{bad_miri_start_panic.stderr => bad_miri_start_unwind.stderr} (71%) diff --git a/library/panic_unwind/src/miri.rs b/library/panic_unwind/src/miri.rs index d941b73b5fac1..4d21e846010e9 100644 --- a/library/panic_unwind/src/miri.rs +++ b/library/panic_unwind/src/miri.rs @@ -8,14 +8,14 @@ type Payload = Box>; extern "Rust" { /// Miri-provided extern function to begin unwinding. - fn miri_start_panic(payload: *mut u8) -> !; + fn miri_start_unwind(payload: *mut u8) -> !; } pub unsafe fn panic(payload: Box) -> u32 { - // The payload we pass to `miri_start_panic` will be exactly the argument we get + // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); - miri_start_panic(Box::into_raw(payload_box) as *mut u8) + miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } pub unsafe fn cleanup(payload_box: *mut u8) -> Box { diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 64e1f3c5b5574..822ba8bf922f8 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -143,7 +143,7 @@ pub struct Thread<'mir, 'tcx> { join_status: ThreadJoinStatus, /// Stack of active panic payloads for the current thread. Used for storing - /// the argument of the call to `miri_start_panic` (the panic payload) when unwinding. + /// the argument of the call to `miri_start_unwind` (the panic payload) when unwinding. /// This is pointer-sized, and matches the `Payload` type in `src/libpanic_unwind/miri.rs`. /// /// In real unwinding, the payload gets passed as an argument to the landing pad, diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 0645c1f176ef7..4ae607e98da8a 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -68,9 +68,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let ret = match ret { None => match link_name.as_str() { - "miri_start_panic" => { - // `check_shim` happens inside `handle_miri_start_panic`. - this.handle_miri_start_panic(abi, link_name, args, unwind)?; + "miri_start_unwind" => { + // `check_shim` happens inside `handle_miri_start_unwind`. + this.handle_miri_start_unwind(abi, link_name, args, unwind)?; return Ok(None); } // This matches calls to the foreign item `panic_impl`. diff --git a/src/tools/miri/src/shims/panic.rs b/src/tools/miri/src/shims/panic.rs index 54f718c46cce1..65b5838cd1437 100644 --- a/src/tools/miri/src/shims/panic.rs +++ b/src/tools/miri/src/shims/panic.rs @@ -3,9 +3,9 @@ //! The core pieces of the runtime are: //! - An implementation of `__rust_maybe_catch_panic` that pushes the invoked stack frame with //! some extra metadata derived from the panic-catching arguments of `__rust_maybe_catch_panic`. -//! - A hack in `libpanic_unwind` that calls the `miri_start_panic` intrinsic instead of the +//! - A hack in `libpanic_unwind` that calls the `miri_start_unwind` intrinsic instead of the //! target-native panic runtime. (This lives in the rustc repo.) -//! - An implementation of `miri_start_panic` that stores its argument (the panic payload), and then +//! - An implementation of `miri_start_unwind` that stores its argument (the panic payload), and then //! immediately returns, but on the *unwind* edge (not the normal return edge), thus initiating unwinding. //! - A hook executed each time a frame is popped, such that if the frame pushed by `__rust_maybe_catch_panic` //! gets popped *during unwinding*, we take the panic payload and store it according to the extra @@ -44,9 +44,9 @@ impl VisitProvenance for CatchUnwindData<'_> { impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {} pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { - /// Handles the special `miri_start_panic` intrinsic, which is called + /// Handles the special `miri_start_unwind` intrinsic, which is called /// by libpanic_unwind to delegate the actual unwinding process to Miri. - fn handle_miri_start_panic( + fn handle_miri_start_unwind( &mut self, abi: Abi, link_name: Symbol, @@ -55,7 +55,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { ) -> InterpResult<'tcx> { let this = self.eval_context_mut(); - trace!("miri_start_panic: {:?}", this.frame().instance); + trace!("miri_start_unwind: {:?}", this.frame().instance); // Get the raw pointer stored in arg[0] (the panic payload). let [payload] = this.check_shim(abi, Abi::Rust, link_name, args)?; @@ -85,7 +85,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // what that is), and returns 1. // The `payload` is passed (by libstd) to `__rust_panic_cleanup`, which is then expected to // return a `Box`. - // In Miri, `miri_start_panic` is passed exactly that type, so we make the `payload` simply + // In Miri, `miri_start_unwind` is passed exactly that type, so we make the `payload` simply // a pointer to `Box`. // Get all the arguments. @@ -141,7 +141,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // We set the return value of `try` to 1, since there was a panic. this.write_scalar(Scalar::from_i32(1), &catch_unwind.dest)?; - // The Thread's `panic_payload` holds what was passed to `miri_start_panic`. + // The Thread's `panic_payload` holds what was passed to `miri_start_unwind`. // This is exactly the second argument we need to pass to `catch_fn`. let payload = this.active_thread_mut().panic_payloads.pop().unwrap(); diff --git a/src/tools/miri/tests/fail/panic/bad_miri_start_panic.rs b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs similarity index 72% rename from src/tools/miri/tests/fail/panic/bad_miri_start_panic.rs rename to src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs index 4b0ae60b10101..deca836a36c61 100644 --- a/src/tools/miri/tests/fail/panic/bad_miri_start_panic.rs +++ b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs @@ -3,10 +3,10 @@ #![feature(c_unwind)] extern "C" { - fn miri_start_panic(payload: *mut u8) -> !; + fn miri_start_unwind(payload: *mut u8) -> !; } fn main() { - unsafe { miri_start_panic(&mut 0) } + 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_panic.stderr b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr similarity index 71% rename from src/tools/miri/tests/fail/panic/bad_miri_start_panic.stderr rename to src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr index 2d96ae4b7de4a..6c85aac050a20 100644 --- a/src/tools/miri/tests/fail/panic/bad_miri_start_panic.stderr +++ b/src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr @@ -1,15 +1,15 @@ 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_panic.rs:LL:CC + --> $DIR/bad_miri_start_unwind.rs:LL:CC | -LL | unsafe { miri_start_panic(&mut 0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding +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_panic.rs:LL:CC + = 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 diff --git a/src/tools/miri/tests/fail/panic/unwind_panic_abort.rs b/src/tools/miri/tests/fail/panic/unwind_panic_abort.rs index c21fa85a90439..88419b1395c73 100644 --- a/src/tools/miri/tests/fail/panic/unwind_panic_abort.rs +++ b/src/tools/miri/tests/fail/panic/unwind_panic_abort.rs @@ -3,11 +3,11 @@ //! Unwinding despite `-C panic=abort` is an error. extern "Rust" { - fn miri_start_panic(payload: *mut u8) -> !; + fn miri_start_unwind(payload: *mut u8) -> !; } fn main() { unsafe { - miri_start_panic(&mut 0); //~ ERROR: unwinding past a stack frame that does not allow unwinding + 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/unwind_panic_abort.stderr b/src/tools/miri/tests/fail/panic/unwind_panic_abort.stderr index 4739c7f2ac6ba..26afe8830cfc5 100644 --- a/src/tools/miri/tests/fail/panic/unwind_panic_abort.stderr +++ b/src/tools/miri/tests/fail/panic/unwind_panic_abort.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: unwinding past a stack frame that does not allow unwinding --> $DIR/unwind_panic_abort.rs:LL:CC | -LL | miri_start_panic(&mut 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^ unwinding past a stack frame that does not allow unwinding +LL | 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 diff --git a/src/tools/miri/tests/utils/miri_extern.rs b/src/tools/miri/tests/utils/miri_extern.rs index ff7990561f2c9..e2983f6c71a7e 100644 --- a/src/tools/miri/tests/utils/miri_extern.rs +++ b/src/tools/miri/tests/utils/miri_extern.rs @@ -56,7 +56,7 @@ extern "Rust" { /// /// This is internal and unstable and should not be used; we give it here /// just to be complete. - pub fn miri_start_panic(payload: *mut u8) -> !; + pub fn miri_start_unwind(payload: *mut u8) -> !; /// Miri-provided extern function to get the internal unique identifier for the allocation that a pointer /// points to. If this pointer is invalid (not pointing to an allocation), interpretation will abort.