https://github.com/google/sanitizers/wiki
https://github.com/google/sanitizers/wiki/AddressSanitizer
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
This tool is very fast. The average slowdown of the instrumented program is ~2x (see AddressSanitizerPerformanceNumbers).
The tool consists of a compiler instrumentation module (currently, an LLVM pass) and a run-time library which replaces the malloc
function.
功能强大,使用方便,默认集成到了gcc 4.8;
集成方便,只需使用clang +一些flag,同时还可以做过滤:例如已知函数的泄露
性能还不错,只是源程序×2的占用,相比valgrind要好得多;
可跟gdb/objdump -ldS使用;