Skip to main content

Module signal_safety

Module signal_safety 

Source
Expand description

JIT signal safety via sigsetjmp/siglongjmp.

JIT-compiled code can crash with SIGILL (case trap) or SIGSEGV (bad memory access). This module provides with_signal_protection which wraps JIT calls so that these signals return a clean error instead of killing the process.

The actual sigsetjmp call lives in C (csrc/sigsetjmp_wrapper.c) because sigsetjmp is a “returns_twice” function. LLVM requires the returns_twice attribute on the caller for correct codegen, but Rust doesn’t expose this attribute. Calling sigsetjmp directly from Rust can cause the optimizer to break the second-return path, especially on aarch64.

Structs§

SigJmpBuf
SignalError
Signal number that caused the jump.

Functions§

install
Install signal handlers for SIGILL, SIGSEGV, SIGBUS on an alternate stack.
with_signal_protection
Wrap a JIT call with signal protection.