Sanitizers
Overview
A number of sanitizers are available in C compilation toolchains that add additional instrumentation into a program. Such instrumentation can be used to detect a wide variety of hard-to-find bugs.
Address Sanitizer
The AddressSanitizer (i.e. ASan) modifies a program to detect memory errors at runtime. These include, but are not limited to:
- Out-of-bounds accesses to heap, stack, and globals
- Use-after-free
- Double-frees and invalid frees
Memory Sanitizer
The MemorySanitizer (i.e. MSan) modifies a program at compile time to catch uninitialized memory use.
Thread Sanitizer
The ThreadSanitizer (i.e. TSan) modifies a program to detect data races.
Undefined Behavior Sanitizer
The UndefinedBehaviorSanitizer (i.e. UBSan) modifies a program at compile time to catch various kinds of undefined behavior during program execution. This includes, but is not limited to, the following checks:
- Array subscript out of bounds
- Bitwise shifts out of bounds for their data type
- Dereferencing misaligned or null pointers
- Signed integer overflow
- Conversion to, from, or between floating-point types which would overflow the destination