From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 4E470A0C53;
	Thu, 14 Oct 2021 08:33:54 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id CFF8840042;
	Thu, 14 Oct 2021 08:33:53 +0200 (CEST)
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by mails.dpdk.org (Postfix) with ESMTP id 92BC840041
 for <dev@dpdk.org>; Thu, 14 Oct 2021 08:33:52 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10136"; a="226380287"
X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="226380287"
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
 by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 13 Oct 2021 23:33:51 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="527404994"
Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16])
 by fmsmga008.fm.intel.com with ESMTP; 13 Oct 2021 23:33:51 -0700
Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by
 ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12; Wed, 13 Oct 2021 23:33:51 -0700
Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by
 orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2242.12 via Frontend Transport; Wed, 13 Oct 2021 23:33:51 -0700
Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.171)
 by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2242.12; Wed, 13 Oct 2021 23:33:50 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=iiIl6OSilacXXSZ0cDuR5H55ejgYVJXU4KlW4XWYTv0+zjlGxyohPQboGE5gXMlqe/NSXUo45j2PNGg8FquqkF5iYpBDBuagC7KvFhOP3xZWMpeW/bz9q1kwcr3YTj37o1fRJvVlj36wjeKdJ8LRUdWL41PsLlfmvVN6/LIXMgSyKHTZu5Bb49V8zNLMlRrqjnmty4tfywAQDmZBt3cnMgaHYE4/WOR5Jy+Gl/3yUk2WAEKvMRt8w77O8BKtOTuWAayUqDJnhbshvYzqXCaIVxAm3xq5NHqVfUFZ3vixlT5lG1VuZEmR09o2q1i/kX6J1U8wS+XJQnV1PEQH8Rn9Vg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=qJc8tVGxw8kxh7Fjt/ePIlSk25/bEjBSRY/XY3uYCFc=;
 b=jw6bw+PCfIVk11dbPu2Gp2kfgg066KdGii61/wLl75MThC++G4XT4rS/SRnIE38+D/OpihLjMdaaTFDRoPjoE08WIzxnp4cA7rJajMGSi6SW08fZHZaEXRdc/6l2BHp1Efqt9s4TQnKK0HzIaYd3jzsbNs50XIselQrqSyBeZdIfSgAdj3so/Ue1YQowvNidNTNVxrAuiyxZ9s1AvCNvYzCdtvt+K1xWmAsvdqnv2JprA3Xo2xsxthn/aeqVLdqOTAGKmYm/oAjxWZKla2x+8/1tOQ+7LaducQ4RcXGv1MD7BDkBwh9Ulpy7Z8KHdCFPMQy+WhYqg3rKiKvJ4t91Gw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; 
 s=selector2-intel-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qJc8tVGxw8kxh7Fjt/ePIlSk25/bEjBSRY/XY3uYCFc=;
 b=T5wkfLO90wdiZanw03CubY4z5/kzSkt5LxsDjpjatPQ3uvJHiLRbhlPpfz1zRk/oh4ngl7Iq1z9JVOvbpVbbr5A6Mmvbi9XsoOCE4DYnpLvw+sK0VaNwtqTXvEylruxjXUklckfABYWIn+GjJ3sc51dFn/3JENcFHVxLkUZUWcU=
Received: from DM8PR11MB5591.namprd11.prod.outlook.com (2603:10b6:8:38::23) by
 DM8PR11MB5671.namprd11.prod.outlook.com (2603:10b6:8:3c::24) with
 Microsoft
 SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.4608.16; Thu, 14 Oct 2021 06:33:49 +0000
Received: from DM8PR11MB5591.namprd11.prod.outlook.com
 ([fe80::3d47:b590:aa2a:d5cc]) by DM8PR11MB5591.namprd11.prod.outlook.com
 ([fe80::3d47:b590:aa2a:d5cc%9]) with mapi id 15.20.4608.016; Thu, 14 Oct 2021
 06:33:49 +0000
From: "Peng, ZhihongX" <zhihongx.peng@intel.com>
To: "Richardson, Bruce" <bruce.richardson@intel.com>, David Marchand
 <david.marchand@redhat.com>
CC: "Burakov, Anatoly" <anatoly.burakov@intel.com>, "Ananyev, Konstantin"
 <konstantin.ananyev@intel.com>, Stephen Hemminger
 <stephen@networkplumber.org>, dev <dev@dpdk.org>, "Lin, Xueqin"
 <xueqin.lin@intel.com>, Thomas Monjalon <thomas@monjalon.net>
Thread-Topic: [dpdk-dev] [PATCH v6 1/2] Enable ASan for memory detector on DPDK
Thread-Index: AQHXtb0yUlb9uW6iB0uZ+PLmDLP2Qau8PHEAgBRolACAAXlmoA==
Date: Thu, 14 Oct 2021 06:33:48 +0000
Message-ID: <DM8PR11MB5591935DFD1FA42D3A012783F0B89@DM8PR11MB5591.namprd11.prod.outlook.com>
References: <20210924100310.4278-1-zhihongx.peng@intel.com>
 <20210930052724.195414-1-zhihongx.peng@intel.com>
 <CAJFAV8yzYJtwpnx+jsaB+X7q7POT86uKC3RS-FB9t7p=kTyGDw@mail.gmail.com>
 <YWaR4vkd+inYiy1d@bricha3-MOBL.ger.corp.intel.com>
In-Reply-To: <YWaR4vkd+inYiy1d@bricha3-MOBL.ger.corp.intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
authentication-results: intel.com; dkim=none (message not signed)
 header.d=none;intel.com; dmarc=none action=none header.from=intel.com;
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 72f5a270-aabc-44b8-4457-08d98edc94f9
x-ms-traffictypediagnostic: DM8PR11MB5671:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <DM8PR11MB5671A4B37510A83D9908133FF0B89@DM8PR11MB5671.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: X4SCpH0rqGioykqI2AfkR9p0pbxDsp9uPqh99HAXMvn9g01jOVzGk2uoPKCLu3bsxj5iFaDS4XYG6/yxB09ByihPFjMnyylc0j/cFwYVi8l7kygxZgm9OlU5a9BUxdHrW+OJ7camlnU1wRlWbiu2IJ4hFWw0yCP5Mz4N6ylT7Ekz1j5ufEYyqOP6lMT6k2q30yPiDTNnksd8z/sfUtmriCoUXVnMrYaW15XHzCcRR+B/L2PAhYcwHbkJ1cm4mjELPbkMUCvPLYTkjf6URSuS70fBXqCQdMiw/8QAuyIi9e5uRSV/BHAdgaFqg2nVmfQ73fgEqFSXhqTKDWFKfNjqLPcUT2f0BUOQFykvV9uCndibGFF2jQizATl5Gb/6hRNjYF1n1EIc39JKO/X90AeNEABsON9DoLL5T7QzWyCwicCdiikgVcn5UPROFNI0siC2B/eNmt8MtUjkDdn2W64EXfwTvioQIHtPjWcv96+lW/y8OQT6xCM+2ogQr2vybg0DyEeV7RGE8ALOzGnsncahJ9Lne4JQZUOKWkjX8FT4WDkmCMPzJOPedHzyWejYZS5lq6zLf/qs3qBmcbq3Yzqi4+awhjmPml2jzctdQvZZyHeGobOcQT9dYFMZ48tKuFAnDKgv3kS0UxI7YJWVlvpfvu41RiDuDB81hUw2o71gjaUmmdpg6qK+3BqeqG+B77Ys+QphpSdUE5jYtXT9Xj4OghgOYY+5f5wc3E3jbETYICXqCL8nBsWFG2fOjkc4qYZ0qG1FvdlPSMl9EqGdPR/0QOeJcAUqiC11XiD/3xbkJgA=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:DM8PR11MB5591.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(366004)(8936002)(38070700005)(122000001)(76116006)(71200400001)(33656002)(26005)(53546011)(6506007)(110136005)(5660300002)(186003)(508600001)(38100700002)(316002)(55016002)(52536014)(66446008)(66476007)(66946007)(54906003)(7696005)(8676002)(4326008)(86362001)(82960400001)(64756008)(2906002)(9686003)(66556008)(83380400001);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NPGms3pcCxiwhVkCXY5Ln6y7nA+XFl/tfe/N1icZdnKTTcGV3KJ8BoxHgqLn?=
 =?us-ascii?Q?c/qBAscn0P+rRjvtBz3Lba7pDW5ubW2C6HfcwJEX6Z/+Oj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?us-ascii?Q?AvOSQDobdxXRY790Ocpne+DKmMg78jT6rGszpiwdhVwZia8bkGlBPm9Tqyty?=
 =?us-ascii?Q?/hGi6V2QbmioEwUMA3ddni7drtzdYndI2sNDcSQMZjx/UO6HIbX74ZPdVjzD?=
 =?us-ascii?Q?Vssvlzv77MOVZ+BAkdqeoW6JM4T0DIMBhaaFNYk3XZdybhSC0gU9STk3XDos?=
 =?us-ascii?Q?eHpmtcsoHXg3rSY/QECMwh0dcHWsXrfMKus8UEg4W5GvfNU5O0b4w9D2ci26?=
 =?us-ascii?Q?Aveju9cjtEH1QdAHADp66NeT+pmXFq5T7nAKn2QfQBCar2y33Nt5kAZKszSk?=
 =?us-ascii?Q?b5lT13PrIwPqph4i1pBZQ302oSBL+xt0YMKCPHHBy/+s+PG+8ZZCOoffB8RX?=
 =?us-ascii?Q?vos=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5591.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 72f5a270-aabc-44b8-4457-08d98edc94f9
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2021 06:33:49.1067 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 5f6LMxRfojfR0Th6ItNttMUF6aPM90eGoQlqXPKyFWdpamWykciarXKOdnOI3OYuBIH+LLxc6NLb39kK4+s4nw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR11MB5671
X-OriginatorOrg: intel.com
Subject: Re: [dpdk-dev] [PATCH v6 1/2] Enable ASan for memory detector on
 DPDK
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

> -----Original Message-----
> From: Richardson, Bruce <bruce.richardson@intel.com>
> Sent: Wednesday, October 13, 2021 4:00 PM
> To: David Marchand <david.marchand@redhat.com>
> Cc: Peng, ZhihongX <zhihongx.peng@intel.com>; Burakov, Anatoly
> <anatoly.burakov@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Stephen Hemminger
> <stephen@networkplumber.org>; dev <dev@dpdk.org>; Lin, Xueqin
> <xueqin.lin@intel.com>; Thomas Monjalon <thomas@monjalon.net>
> Subject: Re: [dpdk-dev] [PATCH v6 1/2] Enable ASan for memory detector on
> DPDK
>=20
> On Thu, Sep 30, 2021 at 10:20:00AM +0200, David Marchand wrote:
> > Hello,
> >
> > I see v6 is superseded in pw, I have been cleaning my queue... maybe my
> fault.
> >
> >
> > On Thu, Sep 30, 2021 at 7:37 AM <zhihongx.peng@intel.com> wrote:
> > >
> > > From: Zhihong Peng <zhihongx.peng@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=
.
> >
> > This patch mixes how to use ASan and instrumenting the DPDK mem
> allocator.
> >
> > I would split this patch in two.
> >
> > The first patch can add the documentation on enabling/using ASan and
> > describe the known issues on enabling it.
> > I'd find it better (from a user pov) if we hide all those details
> > about b_lundef and installation of libasan on Centos.
> >
> > Something like (only quickly tested):
> >
> > diff --git a/config/meson.build b/config/meson.build index
> > 4cdf589e20..7d8b71da79 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -411,6 +411,33 @@ if get_option('b_lto')
> >      endif
> >  endif
> >
> > +if get_option('b_sanitize') =3D=3D 'address'
> > +    asan_dep =3D cc.find_library('asan', required: true)
> > +    if (not cc.links('int main(int argc, char *argv[]) { return 0; }',
> > +                     dependencies: asan_dep))
> > +        error('broken dependency, "libasan"')
> > +    endif
> > +    add_project_link_arguments('-lasan', language: 'c')
> > +    dpdk_extra_ldflags +=3D '-lasan'
> > +endif
> > +
> >  if get_option('default_library') =3D=3D 'both'
> >      error( '''
> >   Unsupported value "both" for "default_library" option.
> >
> >
> > Bruce, do you see an issue with this approach?
> >
>=20
> Apologies for delayed reply on this.
>=20
> No issue with this approach on my end, seems reasonable. Just watch out
> that b_sanitize can have "address,undefined" as a possible value, so if w=
e
> want to support that, we can't just check directly for the literal string
> "address"
>=20
> >
> > Then a second patch adds the rte_malloc instrumentation, with a check
> > at configuration time.
> >
> >      endif
> >      add_project_link_arguments('-lasan', language: 'c')
> >      dpdk_extra_ldflags +=3D '-lasan'
> > +    if arch_subdir =3D=3D 'x86'
> > +        asan_check_code =3D '''
> > +#ifdef __SANITIZE_ADDRESS__
> > +#define RTE_MALLOC_ASAN
> > +#elif defined(__has_feature)
> > +# if __has_feature(address_sanitizer) #define RTE_MALLOC_ASAN #
> endif
> > +#endif
> > +
> > +#ifndef RTE_MALLOC_ASAN
> > +#error ASan not available.
> > +#endif
> > +'''
> > +        if cc.compiles(asan_check_code)
> > +            dpdk_conf.set10('RTE_MALLOC_ASAN', true)
> > +        endif
> > +    endif
> >  endif
> >
>=20
> Apologies, but I haven't been tracking this set in much detail.
> Do we really need this second configuration check? Should it, or could it=
, be
> merged into the check above for the asan library presence?
>=20

All code:
if get_option('b_sanitize') =3D=3D 'address' or get_option('b_sanitize') =
=3D=3D 'undefined'
    if cc.get_id() =3D=3D 'gcc'
        asan_dep =3D cc.find_library('asan', required: true)
        if (not cc.links('int main(int argc, char *argv[]) { return 0; }',
                    dependencies: asan_dep))
            error('broken dependency, "libasan"')
        endif
    endif

    if exec_env =3D=3D 'linux' and arch_subdir =3D=3D 'x86'
        dpdk_conf.set10('RTE_MALLOC_ASAN', true)
    endif
endif

Bruce, is this code correct?
Thanks!
> /Bruce