From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8A7B1A0C45; Mon, 13 Sep 2021 17:23:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12D0C40151; Mon, 13 Sep 2021 17:23:35 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 484C34014F for ; Mon, 13 Sep 2021 17:23:32 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10105"; a="307257207" X-IronPort-AV: E=Sophos;i="5.85,290,1624345200"; d="scan'208";a="307257207" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2021 08:22:26 -0700 X-IronPort-AV: E=Sophos;i="5.85,290,1624345200"; d="scan'208";a="543268896" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.30.142]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 13 Sep 2021 08:22:17 -0700 Date: Mon, 13 Sep 2021 16:22:13 +0100 From: Bruce Richardson To: Stephen Hemminger Cc: "Peng, ZhihongX" , "Burakov, Anatoly" , "Ananyev, Konstantin" , "dev@dpdk.org" , "Lin, Xueqin" Message-ID: References: <20210910020147.148019-1-zhihongx.peng@intel.com> <20210909194756.6addfe73@hermes.local> <20210913080558.4a8b9ae4@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913080558.4a8b9ae4@hermes.local> Subject: Re: [dpdk-dev] [PATCH] Enable AddressSanitizer feature on DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Sep 13, 2021 at 08:05:58AM -0700, Stephen Hemminger wrote: > On Mon, 13 Sep 2021 05:27:12 +0000 > "Peng, ZhihongX" wrote: > > > > -----Original Message----- > > > From: Stephen Hemminger > > > Sent: Friday, September 10, 2021 10:48 AM > > > To: Peng, ZhihongX > > > Cc: Burakov, Anatoly ; Ananyev, Konstantin > > > ; dev@dpdk.org; Lin, Xueqin > > > > > > Subject: Re: [PATCH] Enable AddressSanitizer feature on DPDK > > > > > > On Fri, 10 Sep 2021 02:01:47 +0000 > > > zhihongx.peng@intel.com wrote: > > > > > > > > > > > +if get_option('b_sanitize').startswith('address') > > > > + cflags += '-DRTE_MALLOC_ASAN' > > > > +endif > > > > + > > > > > > This looks great, but can we make it just do-the-right-thing and get rid of the > > > nerd knobs (i.e no meson configure). > > > There are no new meson options being added here. Turning on/off address sanitizing is a built-in meson option that is there already. > > > The address sanitizer already has a way to detect if enabled. > > > > > > GCC uses: > > > __SANITIZE_ADDRESS__ > > > > > > Clang uses: > > > #if defined(__has_feature) > > > # if __has_feature(address_sanitizer) > > > > Tried this method you said. It can run successfully. Because gcc and clang have different > > Methods for determining whether to turn on the asan function, so if you judge the two > > methods in the code, it feels not simple to judge in meson. > > There is already compiler specific #ifdef's why not do this contained in one header file? > > The point is DPDK is trying to get away from having configuration settings if at all > possible. Configuration creates dependency nightmares and also leaves many code paths > as never tested. Not sure I follow your point here. We need some macro to easily tell if we are running with address sanitization enabled or not, so as to avoid having the multi-compiler detection rules all over the place. The only question is where it's better to have this in a header file or a meson.build file. Given your objection and the fact that the meson.build code above looks a little awkward, I'd suggest putting the conditional checks in malloc_elem.h. Is something like the following what you had in mind? #ifdef __SANITIZE_ADDRESS__ #define RTE_MALLOC_ASAN #elif defined(__has_feature) && __has_feature(address_sanitizer) #define RTE_MALLOC_ASAN #endif /Bruce