25. Sanitizers check the edges of the proof¶
Date: 2026-11-21
Status: Accepted
Context¶
Dean wants the runtime core to support compiler-rt's sanitizers (ASan, TSan, UBSan and others). Proved Pia code cannot have the bugs they find, but Pia programs call foreign code, trust extern contracts and assumes, and depend on the verifier, IRGen and codegen being right (ADR 0023). The detail is in docs/stdlib.md.
Decision¶
piac --sanitize=address|thread|undefined|contracts(a list).addressandthreaduse LLVM's ASan and TSan passes, so Pia and C in one binary share one runtime.undefinedturns every unproved goal into a run-time check.contractschecks every foreignensuresand everyassumeat run time.- ASan does not instrument accesses whose bounds were proved, unless
--sanitize-provedasks it to. That build is the check on the verifier. TSan instruments everything. Pia.Mempoisons arena memory for ASan. In a sanitized build,Pia.Rtleaves fatal signals to the sanitizer runtime and adds the Pia trap site through__sanitizer_set_death_callback. Sanitized builds carry DWARF.- The runtimes are built from the pinned llvm-project with rules_foreign_cc, so they match the instrumentation.
- Bazel configs
asan,tsanandubsanset the C++ toolchain features, whichpia_objectmaps to--sanitize.contractsis a Pia build setting.
Consequences¶
- A sanitizer report in proved code is a compiler bug, which makes sanitized test runs a soundness test.
- Each sanitized configuration builds compiler-rt and doubles test time, so CI runs them on main first.
- MemorySanitizer and HWASan are out on macOS arm64. libFuzzer is the next candidate, for the trusted boundary and the image decoders.