On Thu, Jun 10, 2021 at 01:13:52PM +0800, zhihongx.p...@intel.com wrote: > From: Zhihong Peng <zhihongx.p...@intel.com> > > AddressSanitizer (ASan) is a google memory error detect > standard tool. It could help to detect use-after-free and > {heap,stack,global}-buffer overflow bugs in C/C++ programs, > print detailed error information when error happens, large > improve debug efficiency. > > By referring to its implementation algorithm > (https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm), > ported heap-buffer-overflow and use-after-freefunctions to dpdk. > > Here is an example of heap-buffer-overflow bug: > ...... > char *p = rte_zmalloc(NULL, 7, 0); > p[7] = 'a'; > ...... > > Here is an example of use-after-free bug: > ...... > char *p = rte_zmalloc(NULL, 7, 0); > rte_free(p); > *p = 'a'; > ...... > > If you want to use this feature, > you need to use the following compilation options: > -Dc_args='-DRTE_MALLOC_ASAN' > -Db_lundef=false -Db_sanitize=address > Rather than forcing the user to pass in the extra c_args, you can automatically add it from the eal/meson.build files. Something like:
if get_option('b_sanitize').startswith('address'): cflags += '-DRTE_MALLOC_ASAN' endif /Bruce