Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 1 | .. _sanitizer: |
| 2 | |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 3 | ***************** |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 4 | Google Sanitizers |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 5 | ***************** |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 6 | |
| 7 | VPP is instrumented to support `Google Sanitizers <https://github.com/google/sanitizers>`_. |
| 8 | As of today, only `AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_ |
| 9 | is supported and only for the heap. |
| 10 | |
| 11 | AddressSanitizer |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 12 | ================ |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 13 | |
| 14 | `AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_ (aka ASan) is a memory |
| 15 | error detector for C/C++. Think Valgrind but much faster. |
| 16 | |
| 17 | In order to use it, VPP must be recompiled with ASan support. It is implemented as a cmake |
| 18 | build option, so all VPP targets should be supported. For example: |
| 19 | |
| 20 | .. code-block:: console |
| 21 | |
| 22 | # build a debug image with ASan support: |
| 23 | $ make rebuild VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON |
| 24 | .... |
| 25 | |
| 26 | # build a release image with ASan support: |
| 27 | $ make rebuild-release VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON |
| 28 | .... |
| 29 | |
| 30 | # build packages in debug mode with ASan support: |
| 31 | $ make pkg-deb-debug VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON |
| 32 | .... |
| 33 | |
| 34 | # run GBP plugin tests in debug mode with ASan |
| 35 | $ make test-debug TEST=test_gbp VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON |
| 36 | .... |
| 37 | |
| 38 | Once VPP has been built with ASan support, you can use it as usual. When |
| 39 | running under a debugger it can be useful to disable LeakSanitizer which is |
| 40 | not compatible with a debugger and displays spurious warnings at exit: |
| 41 | |
| 42 | .. code-block:: console |
| 43 | |
| 44 | $ ASAN_OPTIONS=detect_leaks=0 gdb --args $PWD/build-root/install-vpp_debug-native/vpp/bin/vpp "unix { interactive }" |
| 45 | .... |
| 46 | |