Skip to main content

Module panic_safe

Module panic_safe 

Source
Expand description

Panic-safety helpers for the C ABI boundary.

Rust panics that unwind across extern "C" into Swift are undefined behaviour. Every extern callback in this crate that invokes user code must wrap that invocation in catch_user_panic, which catches the panic, logs a best-effort diagnostic to stderr, and never returns a panic to its caller.

This is intentionally a single shared helper rather than ad-hoc catch_unwind calls so the diagnostic format and the “stderr-write itself might panic” defence-in-depth stay consistent.

Functions§

catch_user_panic
Run f and swallow any panic it produces.
log_callback_panic
Best-effort logger for panics caught at the C ABI boundary.