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 79354A0C45; Mon, 25 Oct 2021 03:58:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE660407FF; Mon, 25 Oct 2021 03:58:44 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E2FAD4003E for ; Mon, 25 Oct 2021 03:58:42 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10147"; a="253068886" X-IronPort-AV: E=Sophos;i="5.87,179,1631602800"; d="scan'208";a="253068886" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2021 18:58:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,179,1631602800"; d="scan'208";a="723199861" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP; 24 Oct 2021 18:58:41 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) 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; Sun, 24 Oct 2021 18:58:40 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Sun, 24 Oct 2021 18:58:40 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.43) 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; Sun, 24 Oct 2021 18:58:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OzTFIQSKshkNZT1i9Ggb6Wqco5iwmMsUijHKVZ5ZsBy9aM5u1nZ71bosJUyiLSa466HVO18vbvQQ6gP0ZKHGh5GL3uysrzbo7Fb1aL4SXiqk3DoBw+br+uxA+ArWypdStwN3SRi27rlgKlhsuY9IUEzCn83OID/apNnOgTwgzv/uY30L2JbyMiJVSVBkbRQAjzRSsA9XxopwlC0WcDvLGFSzWoNxRdREbUnxB++flXa1IoObq6uL399hFzfvoN7imi3NDxGaGf0qtDdo/XkEdukGZLs+UZfnVPseA5J9EZq2SMl/f7WE3b5B2lZs2onF726QwXAXof2ZmlqN1XJGIA== 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=5WjLRARTnbGVx8gogCfIzf4puOdFR5NbXj1TFe4xosQ=; b=hwQ0EXfbjdA81n43Mxx3dXJkW3HYdKhGfUAs7aYcb6naRxdWmO+hTTkxIvUFntcuDuUgjhUsH5BYweE1L95sko5ManMaCfEfn2jvCLUaFiuYVmmdDkyondeBbr7MygoRqHyy8ZQBLGJl7KXbJod+WxYD5T6R18/IV3cvIYlBmyevfhO4ZYzTa8TyPs4t0FFQS8Nm1Iwq6/6+gA6r87euoXhAons3NKzHVzD7ENMib9mHfMuSDF5T7vkuY8Im5R5V6jEQvvhVh/T5qqjZn6786nbKnv0DSiSHgEThji7F13V0RtvNXqigraVGpqKLq4yG+nMoVSZ/BMnv3RvNeJJ+Tw== 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=5WjLRARTnbGVx8gogCfIzf4puOdFR5NbXj1TFe4xosQ=; b=jYKWFsJ5OSJZH54ROTPeBLIuGZ+iBwcv9JzMbFw/n4JvTL0ggz8+GYLf/vPCPVowuG/cDJ+JnVkKOEXeMzA/LLVPJ1b/Lgt4c4bgGWAGQ1ORCS0yHTDwk4J0KmhRU4ejo1QcStt7gJeD25rPSByIIgsg/BYEypUv2BvNsBTeZUc= Received: from DM8PR11MB5591.namprd11.prod.outlook.com (2603:10b6:8:38::23) by DM8PR11MB5591.namprd11.prod.outlook.com (2603:10b6:8:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.15; Mon, 25 Oct 2021 01:58:37 +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.4628.020; Mon, 25 Oct 2021 01:58:37 +0000 From: "Peng, ZhihongX" To: "david.marchand@redhat.com" , "thomas@monjalon.net" , "Burakov, Anatoly" , "Ananyev, Konstantin" , "stephen@networkplumber.org" , "Dumitrescu, Cristian" , "Mcnamara, John" , "Richardson, Bruce" CC: "dev@dpdk.org" , "Lin, Xueqin" Thread-Topic: [PATCH v13 1/4] enable ASan AddressSanitizer Thread-Index: AQHXxYa7Q/uxs4T2NESnZ9EHVYJ4dqvi9/OA Date: Mon, 25 Oct 2021 01:58:37 +0000 Message-ID: References: <20211019151524.2005442-4-zhihongx.peng@intel.com> <20211020074643.3004385-1-zhihongx.peng@intel.com> In-Reply-To: <20211020074643.3004385-1-zhihongx.peng@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 89de301d-446a-416c-a64f-08d9975af5d0 x-ms-traffictypediagnostic: DM8PR11MB5591: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: c8DRECdNcW74NSv6JSogJIS/eUGyaQd9PgOFQVbfqrLaUi+pN/AQGxPamY8zoS4O0fARzo6bDEESib8IBn9PrRWZil9w7GFAWzaHwDeA5f6yxTUFVccjMOAJg4RqsfZx8ty1RlpJ+KMrWF8tKU45wlMXqPI/ePbRiLIei9VUtzjInrTrBe60/VYPL61IQGldH2h8VxErlfmM7XQnTO8x+sK55sWLM3cIh0KmO5VymTMCD0/s6Poth6u3NZCu7/qdIHmQZypCeeyi80d7bUXeDNaf532b3ZOSN0qUHzktBdRJpe/vBp8+6aUaO3KYFE5XVIMbPl/KW8zwfoyI5wkSWAs0q2+3Qj1dTmBZnd/GAapCjjTOLlwRlzYfq0Mw6hYZMJrUL+dswkAKSKhWWEp5lU+sR/5VCEedIGke1QgPDYeM94ogCDuVjOETeaYUMsXKXhxB1foCxNz0bPzJzTH97pL/nsp6DBsebZ5e9ZwZmkH8INgMStnDcp028rXxrDF+jE7u6ox95xEL1F2c0QeTo0xsIoXSWY6lBUqu6PvHWNY3xWbxgDJyooWPL4iGAzcs9kwV0+kbxUpyT1l9pgdR5DV2kTgJqsXYnoF8GNgHMKXiHChEmhqCaJKF5/BcYx/v0w0djRSbOlYl+BoVmVjCSGjiHAIJNK+oU1BYQ46/oKtO8RLfHdY46Xn6aBJMOTq6dd2ENFOvjdFtU1eBFjeG4mtMAYBKL/kdgEskIiHQwweejEAQGhe0gqJ+vGlVRIIHwrUexGkSgxRW26jiAU/LGWuPN3I/on556W0xhUU8bBb04z6TybKBYcTJrKQDgHYU 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)(6636002)(107886003)(76116006)(64756008)(4326008)(66476007)(66946007)(8676002)(66556008)(38100700002)(508600001)(122000001)(186003)(55016002)(38070700005)(86362001)(33656002)(52536014)(9686003)(8936002)(53546011)(5660300002)(83380400001)(7696005)(316002)(82960400001)(6506007)(54906003)(2906002)(921005)(110136005)(26005)(66446008)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?IphXmCntNc+YDCXwTzSj+iN+AadUVI67eo+dRuJ8wViGBhbQ2NNOmpwDfq3L?= =?us-ascii?Q?gU6J90ysCmtdLmmTe2rEm48PzniCV7aH2gk0QZKSn10zDKETc1FZ+lMrnevO?= =?us-ascii?Q?gkU6WrRC1q3d6yRVaD4tUTEAYw+bgZ3zEAcX5Y5xrzdjNMqGTc2rnMpJFT5z?= =?us-ascii?Q?ZiOuWG123n/Y4Oe91RS/ObPqwKAdWyI3ZkqQbVCklEL85IEy1lkVLZrbjvmX?= =?us-ascii?Q?EPWaZbEjFmAtXiZCV3V5Q5lGQe+La3o6MyQbkW7FFPW8AqzPZt8HHKpMo/IM?= =?us-ascii?Q?fWTk1OQWTFXKex5wDq9+V3ZKlw8Z2nPXS/lopLFwC7AXuEBp5gGo24vMTASZ?= =?us-ascii?Q?CgYmJu4bllv7cc1Obc0l3lrCls3dXvZV4fkZxZzXg1RbLJkMS5hTfGk5ul3E?= =?us-ascii?Q?/YznlP08Wcf4BRvhkzOuFdqtMT2002x/Clr29qBeihf1iR7dXRk5YEEMt1iC?= =?us-ascii?Q?2n1Gs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1i/Rb6?= =?us-ascii?Q?1ZZw2HuYC/eFVKRVK/VFBehsmUb+aUxf3qNam1l+LFtu1pGLROKjXQfYqzXS?= =?us-ascii?Q?oOcHoSN4byfJzNss9MQxIOMK693x80P+rzohDyLrYXoNcvmJPsOujCb9G8qO?= =?us-ascii?Q?w/WeOKhq40H6mVie88P8pSwgfTuKxL+BAHsx6XTRGaHQHaoqttLqjpsS6w/T?= =?us-ascii?Q?EAT51QLVo1VwDw11bjdVo/4hQFh+3WpX5anewCaw4V4+FeTS6F2Tt4DMaPtR?= =?us-ascii?Q?nQ=3D=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: 89de301d-446a-416c-a64f-08d9975af5d0 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Oct 2021 01:58:37.5085 (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: uz9bJs13Fc0pFPsXJYUGwON6PJjvuuDFsFDodvnbP7SYoNjEP4qbn0HRlWk9oiqOyZrja1PSS0PjyuZOKk93gg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR11MB5591 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v13 1/4] enable ASan AddressSanitizer 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" > -----Original Message----- > From: Peng, ZhihongX > Sent: Wednesday, October 20, 2021 3:47 PM > To: david.marchand@redhat.com; thomas@monjalon.net; Burakov, Anatoly > ; Ananyev, Konstantin > ; stephen@networkplumber.org; > Dumitrescu, Cristian ; Mcnamara, John > ; Richardson, Bruce > > Cc: dev@dpdk.org; Lin, Xueqin ; Peng, ZhihongX > > Subject: [PATCH v13 1/4] enable ASan AddressSanitizer >=20 > From: Zhihong Peng >=20 > `AddressSanitizer > `_ (ASan) is = a > widely-used debugging tool to detect memory access errors. > It helps to detect issues like use-after-free, various kinds of buffer ov= erruns > in C/C++ programs, and other similar errors, as well as printing out deta= iled > debug information whenever an error is detected. >=20 > We can enable ASan by adding below compilation options: > -Dbuildtype=3Ddebug -Db_lundef=3Dfalse -Db_sanitize=3Daddress > "-Dbuildtype=3Ddebug": This is a non-essential option. When this option i= s > added, if a memory error occurs, ASan can clearly show where the code is > wrong. > "-Db_lundef=3Dfalse": When use clang to compile DPDK, this option must be > added. >=20 > Signed-off-by: Xueqin Lin > Signed-off-by: Zhihong Peng > Acked-by: John McNamara > --- > v7: 1) Split doc and code into two. > 2) Modify asan.rst doc > v8: No change. > v9: 1) Add the check of libasan library. > 2) Add release notes. > v10:1) Split doc and code into two. > 2) Meson supports asan. > v11:Modify the document. > v12:No change. > v13:Modify the document. > --- > config/meson.build | 16 ++++++++++++++ > devtools/words-case.txt | 1 + > doc/guides/prog_guide/asan.rst | 30 ++++++++++++++++++++++++++ > doc/guides/prog_guide/index.rst | 1 + > doc/guides/rel_notes/release_21_11.rst | 9 ++++++++ > 5 files changed, 57 insertions(+) > create mode 100644 doc/guides/prog_guide/asan.rst >=20 > diff --git a/config/meson.build b/config/meson.build index > 4cdf589e20..f02b0e9c6d 100644 > --- a/config/meson.build > +++ b/config/meson.build > @@ -411,6 +411,22 @@ if get_option('b_lto') > endif > endif >=20 > +if get_option('b_sanitize') =3D=3D 'address' or get_option('b_sanitize')= =3D=3D > 'address,undefined' > + if is_windows > + error('ASan is not supported on windows') > + endif > + > + 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 > + add_project_link_arguments('-lasan', language: 'c') > + dpdk_extra_ldflags +=3D '-lasan' > + endif > +endif > + > if get_option('default_library') =3D=3D 'both' > error( ''' > Unsupported value "both" for "default_library" option. > diff --git a/devtools/words-case.txt b/devtools/words-case.txt index > 0bbad48626..ada6910fa0 100644 > --- a/devtools/words-case.txt > +++ b/devtools/words-case.txt > @@ -5,6 +5,7 @@ API > Arm > armv7 > armv8 > +ASan > BAR > CRC > DCB > diff --git a/doc/guides/prog_guide/asan.rst > b/doc/guides/prog_guide/asan.rst new file mode 100644 index > 0000000000..6888fc9a87 > --- /dev/null > +++ b/doc/guides/prog_guide/asan.rst > @@ -0,0 +1,30 @@ > +.. SPDX-License-Identifier: BSD-3-Clause > + Copyright(c) 2021 Intel Corporation > + > +Running AddressSanitizer > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +`AddressSanitizer > +`_ (ASan) > +is a widely-used debugging tool to detect memory access errors. > +It helps to 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. > + > +AddressSanitizer is a part of LLVM (3.1+) and GCC (4.8+). > + > +Add following meson build commands to enable ASan in the meson build > system: > + > +* gcc:: > + > + -Dbuildtype=3Ddebug -Db_sanitize=3Daddress > + > +* clang:: > + > + -Dbuildtype=3Ddebug -Db_lundef=3Dfalse -Db_sanitize=3Daddress > + > +.. Note:: > + > + a) If compile with gcc in centos, libasan needs to be installed sepa= rately. > + b) If the program is tested using cmdline, you may need to execute t= he > + "stty echo" command when an error occurs. > diff --git a/doc/guides/prog_guide/index.rst > b/doc/guides/prog_guide/index.rst index 89af28dacb..b95c460b19 100644 > --- a/doc/guides/prog_guide/index.rst > +++ b/doc/guides/prog_guide/index.rst > @@ -71,4 +71,5 @@ Programmer's Guide > writing_efficient_code > lto > profile_app > + asan > glossary > diff --git a/doc/guides/rel_notes/release_21_11.rst > b/doc/guides/rel_notes/release_21_11.rst > index 3362c52a73..10f4275b1b 100644 > --- a/doc/guides/rel_notes/release_21_11.rst > +++ b/doc/guides/rel_notes/release_21_11.rst > @@ -173,6 +173,15 @@ New Features > * Added tests to verify tunnel header verification in IPsec inbound. > * Added tests to verify inner checksum. >=20 > +* **Enable ASan AddressSanitizer.** > + > + `AddressSanitizer > + `_ (ASan) > + is a widely-used debugging tool to detect memory access errors. > + It helps to 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 detect= ed. > + >=20 > Removed Items > ------------- > -- > 2.25.1 Hi David, Thomas This is our last stable patch, and we have resolved the comments from the community. Hope to get your comments!