On Thu, Sep 30, 2021 at 3:09 PM <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. > > `AddressSanitizer > <https://github.com/google/sanitizers/wiki/AddressSanitizer>` (ASan) > is a widely-used debugging tool to detect memory access errors. > It helps detect issues like use-after-free, various kinds of buffer > overruns in C/C++ programs, and other similar errors, as well as > printing out detailed debug information whenever an error is detected. > > DPDK ASan functionality is currently only supported Linux x86_64. > Support other platforms, need to define ASAN_SHADOW_OFFSET value > according to google ASan document. > > 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 add below compilation options when compiling code: > -Dbuildtype=debug -Db_lundef=false -Db_sanitize=address > "-Dbuildtype=debug": This is a non-essential option. When this option > is added, if a memory error occurs, ASan can clearly show where the > code is wrong. > "-Db_lundef=false": When use clang to compile DPDK, this option must > be added. > > Signed-off-by: Xueqin Lin <xueqin....@intel.com> > Signed-off-by: Zhihong Peng <zhihongx.p...@intel.com> > --- > devtools/words-case.txt | 1 + > doc/guides/prog_guide/ASan.rst | 112 ++++++++++++++++++ > doc/guides/prog_guide/index.rst | 1 + > lib/eal/common/malloc_elem.c | 26 +++- > lib/eal/common/malloc_elem.h | 204 +++++++++++++++++++++++++++++++- > lib/eal/common/malloc_heap.c | 12 ++ > lib/eal/common/rte_malloc.c | 9 +- > 7 files changed, 360 insertions(+), 5 deletions(-) > create mode 100644 doc/guides/prog_guide/ASan.rst >
I suppose this makes it a v7 since I can see differences when comparing with "previous" v6 series. Please pay attention to versioning and add a changelog when submitting a new revision. Plus, I had comments on v6: https://inbox.dpdk.org/dev/CAJFAV8yzYJtwpnx+jsaB+X7q7POT86uKC3RS-FB9t7p=kty...@mail.gmail.com/ https://inbox.dpdk.org/dev/CAJFAV8w8Zj5xP+giZtYCUz=4ekufrdw5niys9um6xvaw0kt...@mail.gmail.com/ Thanks. -- David Marchand