failed to initiate panic, error 5 on Mac
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
use std::panic::catch_unwind;
fn main() {
for i in 1..=5 {
let _ = catch_unwind(|| panic!("test {}", i));
}
}
I expected to see this happen: The panic would be caught 5 times. When I run this program in a container on Linux I get the following output:
thread 'main' (9) panicked at src/main.rs:5:33:
test 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' (9) panicked at src/main.rs:5:33:
test 2
thread 'main' (9) panicked at src/main.rs:5:33:
test 3
thread 'main' (9) panicked at src/main.rs:5:33:
test 4
thread 'main' (9) panicked at src/main.rs:5:33:
test 5
Instead, this happened: On Mac OS X, I see this output instead.
thread 'main' (705398) panicked at src/main.rs:5:33:
test 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
fish: Job 1, 'cargo run' terminated by signal SIGABRT (Abort)
The process then ends with an abort instead of with a zero exit status.
Meta
rustc --version --verbose:
rustc 1.95.0 (59807616e 2026-04-14)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: aarch64-apple-darwin
release: 1.95.0
LLVM version: 22.1.2
I have also tested nightly and it happens there too.
rustup run nightly rustc --version --verbose:
rustc 1.97.0-nightly (e96c36b6f 2026-05-21)
binary: rustc
commit-hash: e96c36b6f76833388c519561d145492d2c08db4e
commit-date: 2026-05-21
host: aarch64-apple-darwin
release: 1.97.0-nightly
LLVM version: 22.1.6
I can't include a backtrace because that's the underlying problem but I can use lldb and bt.
Backtrace
(lldb) bt
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00000001906ae388 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001906e7848 libsystem_pthread.dylib`pthread_kill + 296
frame #2: 0x00000001905f09e4 libsystem_c.dylib`abort + 124
frame #3: 0x00000001000373c0 main`std::sys::pal::unix::abort_internal at mod.rs:305:14 [opt]
frame #4: 0x000000010003724c main`std::process::abort at process.rs:2533:5 [opt]
frame #5: 0x0000000100036944 main`__rustc::rust_panic at rt.rs:57:13 [opt]
frame #6: 0x000000010001e1e0 main`std::panicking::panic_with_hook at panicking.rs:850:5 [opt]
frame #7: 0x0000000100011b48 main`std::panicking::panic_handler::{closure#0} at panicking.rs:698:13 [opt]
frame #8: 0x0000000100009558 main`std::sys::backtrace::__rust_end_short_backtrace::<std::panicking::panic_handler::{closure#0}, !> at backtrace.rs:182:18 [opt]
frame #9: 0x00000001000121a8 main`__rustc::rust_begin_unwind at panicking.rs:689:5 [opt]
frame #10: 0x00000001000379e0 main`core::panicking::panic_fmt at panicking.rs:80:14 [opt]
frame #11: 0x0000000100003db0 main`main::main::_$u7b$$u7b$closure$u7d$$u7d$::hc2a563d23871e40e + 56
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sample from src/main.rs:5:33 with cargo run on aarch64-apple-darwin and compare it with Linux. Start at the panic path shown in rt.rs, panicking.rs, process.rs, and mod.rs; done means catch_unwind completes all five iterations without aborting and the process exits successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100