-
Notifications
You must be signed in to change notification settings - Fork 2.4k
AddressSanitizer and LeakSanitizer
Here is an overview of how to detect memory errors in OpenVINO using AddressSanitizer and LeakSanitizer tools.
Running OpenVINO tests and tools with sanitizers requires changing build options and environment variables.
- Linux
- Mac OS
Use the ENABLE_SANITIZER
flag while building OpenVINO to enable AddressSanitizer. LeakSanitizer is enabled automatically with AddressSanitizer.
cmake .. -DENABLE_SANITIZER=ON
Inside Intel, you can use pre-built "sanitizer" binaries from nightly artifacts.
Binaries compiled with -DENABLE_SANITIZER=ON
report the runtime memory errors found to stdout. AddressSanitizer error messages start from the "AddressSanitizer" word.
AddressSanitizer and LeakSanitizer use ASAN_OPTIONS and LSAN_OPTIONS environment variables for their configuration.
Run OpenVINO tests and tools with the environment variables set to:
LSAN_OPTIONS=suppressions=<OpenVINO Repository>/tests/lsan/suppressions.txt NEOReadDebugKeys=1 DisableDeepBind=1
If running through Python you need to preload a sanitizer runtime before the python interpreter and tweak its memory allocator with the following environment variables set to:
# note libasan and libstdc++ paths may be different on your system
PYTHONMALLOC=malloc LD_PRELOAD=/lib/x86_64-linux-gnu/libasan.so.5:/lib/x86_64-linux-gnu/libstdc++.so.6
The default AddressSanitizer behavior is to halt execution on the first error found. To continue execution to see other errors add ASAN_OPTIONS=halt_on_error=0
environment variable.
LeakSanitizer reports memory leaks to the stdout on the application exit.
LeakSanitizer distinguishes between directly leaked blocks (not reachable from anywhere) and indirectly leaked blocks (reachable from other leaked blocks). When fixing memory leaks start from "Direct leaks" first. Direct leaks can be a cause of indirect ones. If you have only indirect leaks those are the result of cyclic references.
-
An old version of OpenVINO GPU plugin uses compute-runtime which is incompatible with AddressSanitizer and LeakSanitizer: https://github.com/intel/compute-runtime/issues/376
-
AddressSanitizer and LeakSanitizer may conflict with signal handlers such as libSegFault.so
© Copyright 2018-2024, OpenVINO team
- Home
- General resources
- How to build
-
Developer documentation
- Inference Engine architecture
- CPU plugin
- GPU plugin
- HETERO plugin architecture
- Snippets
- Sample for IE C++/C/Python API
- Proxy plugin (Concept)
- Tests