Validation & Sanitizers
Use the preset-driven validation path first, then pick the sanitizer that matches the failure mode you are investigating.
Quick reference
| Preset | Best for | Notes |
|---|---|---|
asan | heap/stack overflows, use-after-free, double free | Benchmarks are disabled in this preset |
tsan | data races, unsafe synchronization | This preset switches to clang / clang++ |
ubsan | undefined behavior, invalid shifts, signed overflow | Good follow-up after functional fixes |
AddressSanitizer
bash
cmake --preset=asan
cmake --build build/asan
ctest --preset=asanUse asan when you suspect invalid memory access, lifetime bugs, or accidental buffer overruns.
ThreadSanitizer
bash
cmake --preset=tsan
cmake --build build/tsan
ctest --preset=tsanUse tsan for concurrent code paths. The preset already selects clang / clang++, which is the supported toolchain in this repository.
UndefinedBehaviorSanitizer
bash
cmake --preset=ubsan
cmake --build build/ubsan
ctest --preset=ubsanUse ubsan to surface undefined behavior that may stay invisible in normal debug or release builds.
Suggested workflow
- Start with
debugorreleaseto reproduce the issue normally. - Run
asanfor memory-safety problems. - Run
tsanfor concurrency changes or flaky parallel tests. - Run
ubsanbefore closing work that touches low-level arithmetic, casts, or layout assumptions.
The repository keeps these as separate presets on purpose: they stay easy to discover, easy to automate, and do not hide compiler-specific sanitizer constraints behind extra wrapper scripts.