-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #69999 - RalfJung:miri-unwind, r=oli-obk
adjust Miri to needs of changed unwinding strategy As expected, #67502 broke unwinding in Miri. To fix it we have to adjust parts of the engine and the panic runtime, which this PR does. The Miri-side changes are in rust-lang/miri#1227. Cc @oli-obk @Aaron1011 @Mark-Simulacrum @Amanieu
- Loading branch information
Showing
8 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Unwinding panics for Miri. | ||
use alloc::boxed::Box; | ||
use core::any::Any; | ||
|
||
// The type of the payload that the Miri engine propagates through unwinding for us. | ||
// Must be pointer-sized. | ||
type Payload = Box<Box<dyn Any + Send>>; | ||
|
||
pub unsafe fn panic(payload: Box<dyn Any + Send>) -> u32 { | ||
// The payload we pass to `miri_start_panic` 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); | ||
core::intrinsics::miri_start_panic(Box::into_raw(payload_box) as *mut u8) | ||
} | ||
|
||
pub unsafe fn cleanup(payload_box: *mut u8) -> Box<dyn Any + Send> { | ||
// Recover the underlying `Box`. | ||
let payload_box: Payload = Box::from_raw(payload_box as *mut _); | ||
*payload_box | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters