Skip to content

Commit c5202b3

Browse files
authored
Rollup merge of #87787 - hyd-dev:c-unwind, r=RalfJung
Use `C-unwind` ABI for `__rust_start_panic` in `panic_abort` The function originally has `C` ABI but is called using `C-unwind` ABI in `std`: https://github.com/rust-lang/rust/blob/d4ad1cfc63ba5824196bfb2370451ddb5af2e020/library/std/src/panicking.rs#L49-L54 Which might be [problematic](rust-lang/miri#1745 (comment)) and triggers this [Miri error](#87778 (comment)): ``` error: Undefined Behavior: calling a function with ABI C using caller ABI C-unwind --> /home/hyd-dev/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:672:9 | 672 | __rust_start_panic(obj) | ^^^^^^^^^^^^^^^^^^^^^^^ calling a function with ABI C using caller ABI C-unwind | = 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 ``` Changing the ABI of the function to `C-unwind` fixes the error above.
2 parents a4262cc + 7520ea9 commit c5202b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/panic_abort/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![feature(staged_api)]
1616
#![feature(rustc_attrs)]
1717
#![feature(asm)]
18+
#![feature(c_unwind)]
1819

1920
#[cfg(target_os = "android")]
2021
mod android;
@@ -30,7 +31,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
3031

3132
// "Leak" the payload and shim to the relevant abort on the platform in question.
3233
#[rustc_std_internal_symbol]
33-
pub unsafe extern "C" fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
34+
pub unsafe extern "C-unwind" fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
3435
// Android has the ability to attach a message as part of the abort.
3536
#[cfg(target_os = "android")]
3637
android::android_set_abort_message(_payload);

0 commit comments

Comments
 (0)