Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK
From: David Christensen <hidden>
Date: 2021-09-20 19:41:30
On 9/18/21 12:21 AM, Peng, ZhihongX wrote:
quoted
-----Original Message----- From: David Christensen <redacted> Sent: Saturday, September 18, 2021 4:51 AM To: Peng, ZhihongX <redacted>; Burakov, Anatoly [off-list ref]; Ananyev, Konstantin [off-list ref]; stephen@networkplumber.org Cc: dev@dpdk.org; Lin, Xueqin <redacted> Subject: Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDKquoted
quoted
quoted
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": Display code information when coredump occurs in the program. "-Db_lundef=false": It is enabled by default, and needs to be disabled when using asan.On initial inspection, it appears ASAN functionality doesn't work with DPDK on PPC architecture. I tested the patch with several compiler versions (gcc 8.3.1 from RHEL 8.3 through gcc 11.2.1 from the IBM Advanced Toolchain 15.0) and observed the following error when running testpmdwith ASAN enabled:quoted
quoted
AddressSanitizer:DEADLYSIGNAL==========================================================quoted
quoted
======= ==49246==ERROR: AddressSanitizer: SEGV on unknown address 0x0000a0077bd0 (pc 0x000010b4eca4 bp 0x7fffffffe150 sp 0x7fffffffe150 T0) ==49246==The signal is caused by a UNKNOWN memory access. #0 0x10b4eca4 inasan_set_shadow ../lib/eal/common/malloc_elem.h:120quoted
quoted
#1 0x10b4ed68 inasan_set_zone ../lib/eal/common/malloc_elem.h:135quoted
quoted
#2 0x10b4ee90 in asan_clear_split_alloczone ../lib/eal/common/malloc_elem.h:162 #3 0x10b51f84 in malloc_elem_alloc ../lib/eal/common/malloc_elem.c:477 ... Can you incorporate an exception for PPC architecture with this patch while I look into the problem further? DaveWe do not have a ppc platform, so there is no adaptation. doc/guides/prog_guide/asan.rst has stated that we currently only support Linux x86_64. You can adapt according to the following documents,the main work is to modify the base address according to the platform.quoted
Documents: https://github.com/google/sanitizers/wiki/AddressSanitizer https://github.com/llvm/llvm-project/tree/main/compiler-rtUnderstand you don't have such a platform. I looked into it and suggest the following change in lib/eal/common/malloc_elem.h: #define ASAN_SHADOW_GRAIN_SIZE 8 #define ASAN_SHADOW_SCALE 3 #ifdef RTE_ARCH_PPC_64 #define ASAN_SHADOW_OFFSET 0x020000000000 #else #define ASAN_SHADOW_OFFSET 0x00007fff8000 #endif #define ASAN_MEM_FREE_FLAG 0xfd #define ASAN_MEM_REDZONE_FLAG 0xfa #define ASAN_MEM_TO_SHADOW(mem) (((mem) >> ASAN_SHADOW_SCALE) + ASAN_SHADOW_OFFSET) This resolves the segmentation error I receive. DaveGreat, good information for dpdk asan tool. Because we can't do many tests, so when this patch is merged into the main line, you can submit the ppc architecture patch.
If your argument is that this is x86 only then please ensure it can't be enabled on non-x86 platforms such as ARM and PPC. I can then easily submit a follow-on patch to enable for PPC. As the patch currently stands it enables ASAN on a non-tested platform and provides an unexpected error for some users when it can easily be avoided. I'd advise not accepting the patch as currently presented. Dave