llvmglue
The project's own code inside libllvm: what every in-process LLVM user shares.
Detailed description
libnative, libfirmware and libkiln all depend on libllvm and on nothing else in common, so the rules for LLVM's process-global state live here.
Function documentation
runSafely
bool llvmglue::runSafely(llvm::CrashRecoveryContext &context, int work)
Runs work in context, and after a recovered crash gives the calling thread its signal mask back.
It returns what `CrashRecoveryContext::RunSafely()` returns: false when work crashed and the context recovered it.
LLVM's crash handler leaves the crashed code with `longjmp()`, which does not restore the signal mask. The handler unblocks only the signal that it caught, so the mask that the kernel gave the handler stays on the thread. With LLVM's own handler that mask is the old one. Under ThreadSanitizer the handler runs inside TSan's, which blocks every signal. A recovered crash then left the thread with every signal but the caught one blocked, and each thread that it started later inherited that mask. SIGCHLD then never came, so Qt's QProcess never saw a child end: in testKilnCompile, every case after aCrashInsideClangFailsAlone waited for a program that had exited (y8 on 2026-10-19, honeybadger32 on 2026-10-22, §KN-B2c).
On Windows a thread has no signal mask, and this is RunSafely().
Classes
| Class | What it is |
|---|---|
| CompileGuard | Guard for one compile, assembly or code generation |
| GlobalStateGuard | Holds LLVM's process-global state for one job, shared or exclusive |
| LinkGuard | Guard for one `lld::lldMain` call. Always exclusive |