Address Sanitizer (ASan)
What is "Address Sanitizer"?
Address Sanitizer is a tool for detection memory error, like stack over flow, buffer over follw, memory leak…etc.
How to use it ?
- set the compiler flag
- including the LSan, so when you enable ASan, the LSan also be enabled.
You can use
ASAN_OPTIONS=detect_leaks=1 to enable it
ASAN_OPTIONS=detect_leaks=0 to disenable it
Here are others options:
- halt_on_error=0:non-stop when memory happens
- malloc_context_size=15
- log_path=/path/to/logfile
- suppressions=$SUPP_FILE
- running the code
or add -static-libasan for static library into the target program
How to work
ref