Introduction
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
This tool is very fast. The average slowdown of the instrumented program is ~2x (see PerformanceNumbers).
The tool consists of a compiler instrumentation module (currently, an LLVM pass) and a run-time library which replaces the malloc function.
The tool works on x86 Linux and Mac.
See also:
AddressSanitizerAlgorithm -- if you are curious how it works.
ComparisonOfMemoryTools
Getting AddressSanitizer
The Chromium team periodically updates LLVM/Clang binaries, which now include AddressSanitizer support. Simply execute the following:
mkdir -p tools/clang
cd tools/clang
cd ../../
tools/clang/scripts/update.sh
# Now use third_party/llvm-build/Release+Asserts/bin/{clang,clang++}
Read more: Google code
QR:
0 comments:
Post a Comment