1*6e029025SZhihong Peng.. SPDX-License-Identifier: BSD-3-Clause 2*6e029025SZhihong Peng Copyright(c) 2021 Intel Corporation 3*6e029025SZhihong Peng 4*6e029025SZhihong PengRunning AddressSanitizer 5*6e029025SZhihong Peng======================== 6*6e029025SZhihong Peng 7*6e029025SZhihong Peng`AddressSanitizer 8*6e029025SZhihong Peng<https://github.com/google/sanitizers/wiki/AddressSanitizer>`_ (ASan) 9*6e029025SZhihong Pengis a widely-used debugging tool to detect memory access errors. 10*6e029025SZhihong PengIt helps to detect issues like use-after-free, various kinds of buffer 11*6e029025SZhihong Pengoverruns in C/C++ programs, and other similar errors, as well as 12*6e029025SZhihong Pengprinting out detailed debug information whenever an error is detected. 13*6e029025SZhihong Peng 14*6e029025SZhihong PengAddressSanitizer is a part of LLVM (3.1+) and GCC (4.8+). 15*6e029025SZhihong Peng 16*6e029025SZhihong PengEnabling ASan is done by passing the -Db_sanitize=address option to the meson build system, 17*6e029025SZhihong Pengsee :ref:`linux_gsg_compiling_dpdk` for details. 18*6e029025SZhihong Peng 19*6e029025SZhihong PengThe way ASan is integrated with clang requires to allow undefined symbols when linking code. 20*6e029025SZhihong PengTo do this, the -Db_lundef=false option must be added. 21*6e029025SZhihong Peng 22*6e029025SZhihong PengAdditionally, passing -Dbuildtype=debug option might help getting more readable ASan reports. 23*6e029025SZhihong Peng 24*6e029025SZhihong PengExample:: 25*6e029025SZhihong Peng 26*6e029025SZhihong Peng - gcc: meson setup -Db_sanitize=address <build_dir> 27*6e029025SZhihong Peng - clang: meson setup -Db_sanitize=address -Db_lundef=false <build_dir> 28*6e029025SZhihong Peng 29*6e029025SZhihong Peng.. Note:: 30*6e029025SZhihong Peng 31*6e029025SZhihong Peng - The libasan package must be installed when compiling with gcc in Centos/RHEL. 32*6e029025SZhihong Peng - If the program is tested using cmdline, you may need to execute the 33*6e029025SZhihong Peng "stty echo" command when an error occurs. 34