Created by: kbinias
This PR adds support for Sanitizers:
- AddressSanitizer (for a fast memory error detector)
- LeakSanitizer (for a run-time memory leak detector)
- MemorySanitizer (for a detector of uninitialized reads)
- ThreadSanitizer (for detect data races)
These Sanitizers are based on compiler instrumentation, therefore a rebuild is required in order to use these tools. Sanitizers are implemented in Clang starting 3.1 and GCC starting 4.8 and supported on Linux x86_64 machines. AddressSanitizer and UndefinedBehaviorSanitizer are also available on macOS.
Usage
You can enable the Sanitizers with SANITIZE_ADDRESS, SANITIZE_LEAK, SANITIZE_MEMORY, SANITIZE_THREAD options in your CMake configuration. You can do this by passing e.g. -DSANITIZE_ADDRESS=ON
on your command line. The Sanitizers check your program, while it's running.
Only one Sanitizer is allowed in compile time.
Usefully option is halt_on_error
e.g. for ThreadSanitizer export TSAN_OPTIONS="halt_on_error=1"
to exit after first reported error.
IMO: maybe it would be nice to connect PaddlePaddle CI with these Sanitizers in future.
Documentation
Comprehensive documentation is here https://github.com/google/sanitizers