Skip to main content

try_call_raw

Function try_call_raw 

Source
unsafe fn try_call_raw(
    body: unsafe extern "C-unwind" fn(*mut c_void) -> SEXP,
    body_data: *mut c_void,
) -> Caught
Expand description

Call body(body_data), hidden from the caller’s handlers and restarts (a new top-level context, R_ToplevelExec), with error conditions caught (catch_error).

R_tryCatchError alone is not enough here: the caller’s calling handlers would see the evaluation’s warnings, and an exiting handler or restart of the caller would jump through the Rust frames. R_ToplevelExec gives the isolation R_tryEval gives, and stops any jump that is not an error.

§Safety

R’s main thread (the checked FFI routes a worker’s call there); body(body_data) is sound to call, and what it reads is rooted.