-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust sometimes emits calls to _Unwind_Resume on opt-level = 0 with panic = abort #53301
Comments
As of #67502, this happens at any opt-level because of libstd itself containing these symbols. |
(and libbacktrace) |
Triage: Please provide a minimal way to reproduce the problem (if this still is a problem). Thanks! |
Closing since there is no reproduction. |
I'm fairly certain this is still an issue as the standard library is still compiled with panic=unwind. The default |
We ran into this #134299, so here's a reproduction that works only on the x86_64-gnu-nopt CI runner: //@ run-pass
//@ compile-flags: -Cpanic=abort
//@ ignore-emscripten no no_std executables
#![feature(lang_items, rustc_private)]
#![no_std]
#![no_main]
#[macro_use] extern crate alloc;
use core::alloc::{GlobalAlloc, Layout};
use alloc::string::ToString;
extern crate libc;
struct MyAllocator;
unsafe impl GlobalAlloc for MyAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// This is unsound because we ignore alignment, but good enough for this test.
libc::malloc(layout.size()) as _
}
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
libc::free(ptr as _);
}
}
#[global_allocator]
static A: MyAllocator = MyAllocator;
#[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
loop {}
}
#[no_mangle]
extern "C" fn rust_eh_personality() {
loop {}
}
#[no_mangle]
extern "C" fn main(_argc: core::ffi::c_int, _argv: *const *const u8) -> core::ffi::c_int {
let s = format!("{}", 1_isize);
assert_eq!(s, "1".to_string());
let s = format!("test");
assert_eq!(s, "test".to_string());
let s = format!("{test}", test=3_isize);
assert_eq!(s, "3".to_string());
let s = format!("hello {}", "world");
assert_eq!(s, "hello world".to_string());
0
} |
Also, this is a duplicate of #47493. |
Closing in favor of #47493 as that has a lot more existing analysis. |
I don't think this is intentional. I'm working on a no_std project and for the first time tried to compile with the debug profile and there seem to be undefined references to _Unwind_Resume even though panic = "abort" is specified. opt-level = 1 seems to get rid of those calls.
The text was updated successfully, but these errors were encountered: