AddressSanitizer (ASan) is a compiler technology that checks addressability-related memory errors with some add-on checks. It consists of two parts: compiler instrumentation and runtime library. To put it in the simplest way,
- The compiler instruments global variables, stack frames, and heap allocations to track shadow memory.
- The compiler instruments memory access instructions to check shadow memory.
- In case of an error, the inserted code calls a callback (implemented in the runtime library) to report an error with a stack trace. Normally the program will exit after the error message is printed.
Clang 3.1 implemented AddressSanitizer in 2011.
GCC 4.8 integrated AddressSanitizer in 2012.
MSVC (starting in Visual Studio 2019 version 16.9) added /INFERASANLIBS
.