Skip to main content

call_unwinding

Function call_unwinding 

Source
pub(crate) unsafe fn call_unwinding(
    fun: unsafe extern "C-unwind" fn(*mut c_void) -> SEXP,
    data: *mut c_void,
) -> SEXP
Expand description

Call fun(data) in its own R_UnwindProtect, in the caller’s R context, and return its value.

An R exit from fun (an error, an exiting handler of the caller’s tryCatch(), a restart, an interrupt) stops at that frame, never jumping over a Rust frame. Its cleanup turns the exit into a Rust unwind (RUnwind); the boundary resumes it.

§Safety

R’s main thread, inside a miniextendr boundary (a #[miniextendr] body, a with_r_unwind_protect* closure, a guarded callback). fun holds nothing to drop across an R jump (it is called from C), and what data points to outlives the call. The result is unprotected.