abort: raise(SIGABRT) + _Exit instead of ud2

Previously abort() called core::intrinsics::abort() which compiles to
the ud2 instruction, generating an Invalid Opcode fault. The kernel
logs this as 'UNHANDLED EXCEPTION' and kills the process, but the
fault message is alarming and doesn't reflect the actual intent
(SIGABRT from process self-termination).

This change uses the POSIX-compliant abort sequence: raise(SIGABRT)
first (default handler terminates the process), then _Exit(134) as
fallback if the signal handler returns. Six sites updated:
stdlib abort, assert __assert_fail, lib.rs relibc_panic/oom/_Unwind_Resume,
start.rs relibc_verify_host.

The proc-manager-fallback in redox-rt/src/sys.rs retains
core::intrinsics::abort() — that path is a true 'system unreachable'
last resort where raise/_Exit cannot succeed.
This commit is contained in:
Red Bear OS
2026-06-28 04:00:30 +03:00
parent fc8f0ec4fd
commit 4e40dc538c
4 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -20,5 +20,5 @@ pub unsafe extern "C" fn __assert_fail(
eprintln!("{}: {}:{}: Assertion `{}` failed.", func, file, line, cond);
core::intrinsics::abort();
crate::header::stdlib::abort();
}
+2 -1
View File
@@ -117,7 +117,8 @@ pub unsafe extern "C" fn a64l(s: *const c_char) -> c_long {
#[unsafe(no_mangle)]
pub unsafe extern "C" fn abort() -> ! {
log::error!("Abort");
intrinsics::abort();
crate::header::signal::raise(crate::header::signal::redox::SIGABRT as c_int);
_Exit(128 + crate::header::signal::redox::SIGABRT as c_int);
}
#[cfg(not(target_pointer_width = "64"))]
+3 -3
View File
@@ -69,7 +69,7 @@ pub extern "C" fn relibc_panic(pi: &::core::panic::PanicInfo) -> ! {
let mut w = platform::FileWriter::new(2);
let _ = w.write_fmt(format_args!("RELIBC PANIC: {}\n", pi));
core::intrinsics::abort();
crate::header::stdlib::abort();
}
#[cfg(not(test))]
@@ -100,7 +100,7 @@ pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! {
layout.align()
));
core::intrinsics::abort();
crate::header::stdlib::abort();
}
#[cfg(not(test))]
@@ -113,5 +113,5 @@ pub extern "C" fn _Unwind_Resume() -> ! {
let mut w = platform::FileWriter::new(2);
let _ = w.write_str("_Unwind_Resume\n");
core::intrinsics::abort();
crate::header::stdlib::abort();
}
+1 -1
View File
@@ -78,7 +78,7 @@ unsafe fn copy_string_array(array: *const *const c_char, len: usize) -> Vec<*mut
#[unsafe(no_mangle)]
pub unsafe fn relibc_verify_host() {
if !Sys::verify() {
intrinsics::abort();
stdlib::abort();
}
}
#[unsafe(link_section = ".init_array")]