Address sanitizer
AddressSanitizer (aka ASan) is a memory error detector for C/C++. It finds:
- Use after free (dangling pointer dereference)
- Heap buffer overflow
- Stack buffer overflow
- Global buffer overflow
- Use after return
- Use after scope
- Initialization order bugs
- Memory leaks
Each bullet point links to an example of what it looks like when ASan detects an error. They all start similar (ERROR: AddressSanitizer
...) except for Memory leaks (ERROR: LeakSanitizer...).
UndefinedBehavior Sanitizer
UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior detector. UBSan modifies the program at compile-time to catch various kinds of undefined behavior during program execution.
A list of available checks can be found here. The flag -fsanitize=undefined will perform all checks except for float-divide-by-zero
, unsigned-integer-overflow
, implicit-conversion
, local-bounds
and the nullability-*
group of checks.
Depending on the severity, error detection look like the following: