rust-sanitizers-miri
Installation
SKILL.md
Rust Sanitizers and Miri
1. Select the tool
Select the tool from the bug class. Each tool finds its own class and misses the others.
| Bug class | Tool | Does not find it |
|---|---|---|
| Aliasing breach, invalid value, provenance error in Rust | Miri | ASan, HWASan, MTE: they do not model Rust rules |
| Heap overflow, use-after-free, double free at runtime | ASan, HWASan or MTE | Miri, when the path reaches foreign code |
| Data race between threads | TSan, or Miri with -Zmiri-many-seeds |
ASan |
| Read of uninitialized memory | Miri, or MSan with every object instrumented | ASan |
| Integer overflow or null dereference in a C or C++ dependency | UBSan: clang -fsanitize=undefined on that dependency |
Miri (does not run C); rustc (has no UBSan option) |
| Memory error inside a C or C++ dependency | ASan, HWASan or MTE | Miri |
Miri knows the Rust rules but cannot execute foreign code. Sanitizers execute
foreign code but do not know the Rust aliasing model. For a crate that has
unsafe code and FFI, run both.