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 73B0BA0505; Tue, 17 May 2022 17:25:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6441B40041; Tue, 17 May 2022 17:25:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E8CA34003C for ; Tue, 17 May 2022 17:25:42 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24HAiBe3008527; Tue, 17 May 2022 08:25:42 -0700 Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3g4a7a1577-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 May 2022 08:25:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AcTVA9CgZHTNL9RdVwL9bOxRG9Hi9koRNOhVA4KyqsoLpdk7eVFc1egnj1pFrIdV4DhHzspSIbaTGAzwH6Vae/t/VM7uTqRXvfeJOz78DTBq5zOUZK+xNrISkzlwPX6hS/rX1Kuf92E7ap8ayA1yyg/FtKgTv9g9HHjGIzsLxY5XSNhGlwvNkLPAdT3XizgTLna5a6fMYpHEdhiMhkg+Gjn12Ku2HIStj1dTiht8tD9KpjNvy5PHIbj/HOVR6tt2/nsZWpk9gc66h3iK2btRvv9gzF1mD4lCP9/Lf5UPISGFrK/Fs9QtAgAkhUH5i00V4QHpKELe6mwuceXuu3mlAA== 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=8QkBSGbYcUq4N9olcJZwpKwhQwwszCqucDx3O2FcVBg=; b=LFoyXdqjO/DaZuA92lxz8cQfmpG0Hgk5OsxSBtLSjAZs8adraxMtdj9K/1CL4QiXDjr+fPI7OlBTlYv0cdfkMnuNUIpjAwnRi62ZWL7zoIKVhwBucM8ePIxK+8l6cqtOgKUj/g9ChXNmK5ftUTlO8U0oZMsUCasrTY+CqvcsXWhXzk+FWHjGMIe6r3xYbB8rMUiMj1CM7yUy2Eb8JdnP38S2J9hUN7cP5E6xUcVU+bINF5wdp7dOC0M+cG5g4CsizsdLk8eqqKX8HBBhN5S37133Xnqr5LxQVSWFSfYqr7i8RLR4tRKnv9rQrs9Govqvv8kYLfI9BH2kghW1ZjQonw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8QkBSGbYcUq4N9olcJZwpKwhQwwszCqucDx3O2FcVBg=; b=a+3MuCEKDKN4yFK1Hhzws0SqVRtjrrjrnY5ijarEo3okX4wv7EbC+LeK7sZ8ZMkgWUIHjmeqLaFeg8cAKRJ6MBNJNI1RjyZuTpqtymbNeMZc+GCjfcNlz0I6UJT3Th66GYimuy4OMH34ye3Kb7GZ/VYOx0SH9zZsSpyEfURoPCA= Received: from BN9PR18MB4204.namprd18.prod.outlook.com (2603:10b6:408:119::18) by CY4PR1801MB1975.namprd18.prod.outlook.com (2603:10b6:910:7e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18; Tue, 17 May 2022 15:25:23 +0000 Received: from BN9PR18MB4204.namprd18.prod.outlook.com ([fe80::8c25:d1fb:d1a2:23cb]) by BN9PR18MB4204.namprd18.prod.outlook.com ([fe80::8c25:d1fb:d1a2:23cb%6]) with mapi id 15.20.5273.013; Tue, 17 May 2022 15:25:23 +0000 From: Harman Kalra To: "zhichaox.zeng@intel.com" , "dev@dpdk.org" , "qiming.yang@intel.com" Subject: RE: [EXT] [DPDK] eal/linux: fix segfaults due to thread exit order Thread-Topic: [EXT] [DPDK] eal/linux: fix segfaults due to thread exit order Thread-Index: AQHYacTPOhihIrxbcEmQKQiaCSpFfq0jMMTw Date: Tue, 17 May 2022 15:25:23 +0000 Message-ID: References: <20220517160444.413819-1-zhichaox.zeng@intel.com> In-Reply-To: <20220517160444.413819-1-zhichaox.zeng@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 58f52b5d-cfff-420e-e072-08da3819763b x-ms-traffictypediagnostic: CY4PR1801MB1975:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: nSaZFt1sOaB9y0BRENPgh6IbZv+6CzgJdTHpzxoAyPYlKjWwsBrkYw2RIZnwuG00stzz3bjOpPvb4Mhxhdr4/Y3oQLITjrRhnOwRPvGND8qi/gK+N+7rO0xTLBQlvxyhTdtPwBd968zLPZEUpeHEEHpKqZyUDb+5t4amTjAtObDlp5oP61qHVZ2wzbHtgXwOyZNVqK0hN/b/e1bjktsJsZzxY8n2YrFvxOAq0xJRYx6AvqiZSPvCFKEc/q7ua20MxKteFLRnea1vC8OM85Gd/uw1n0kUUJFnhc5PDoLn/XCSi4xstWhA4/Oyw9XPgI2hifyfLNVeqozdJIIoJ00ho4iLNkMG466EaGS5eYp8Iyhkv+IHzJEsK1yHM9gm1wPF6PUVKjSew9HMTSEABf10Rpj0x9nvGpzwv+9jrPDk13ftykolA1roaFMgYmB0q5DHl6UCL9ejJi9xKKGkNXfXnpv/3wzbMHQ23aOiU4Nk2rfin+84UTyEC0WmCapgZ/MXnJaDKM6yhhXVdNj7FTTxuvITGs2RCnsznPy4Tn2X9jcjFjHOg3GbmHUuvCIehxwUf2M2OCcRhS2Rfb16opQ7iZJSY1pHtgYa0x+tzGdl85Rdjeuhs2JoxCs1LPLLwFqJtvHdVusKsQG8MyU7/5ZWIux6K7QJa1y0iLxtnJQxUgMtClSwcxcoTAhPb2THAz9yXKhM8LNO9ycSVafKErtj7g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR18MB4204.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(316002)(66476007)(55016003)(122000001)(8676002)(7696005)(38100700002)(86362001)(2906002)(5660300002)(52536014)(64756008)(66446008)(6506007)(186003)(71200400001)(9686003)(110136005)(53546011)(8936002)(33656002)(508600001)(83380400001)(66556008)(76116006)(38070700005)(66946007)(26005); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?t3Co09FZ4r+rLxZxQiW3zFC1MTfljTg1FdoozApINHWb7Czbf5MPB6Y6+RgH?= =?us-ascii?Q?wyWqJSjxeapVr+KCQpnRoIU+/mGSrL6hyRebloNnBD3+3Pkg0cR1uA+djMw0?= =?us-ascii?Q?mrhT4I1Btt36ZMPg24M/aCgmiK36IYYTx7h4UaZyJAdhXGoTuDT57twnht7G?= =?us-ascii?Q?oejtBwIV28muZOOFjXDNpt9BUx1HHWehxC8aTXFAbJTxwEwEMvdhiVeMp4k6?= =?us-ascii?Q?SsLoA1dElFqKdbpVUls05ZZELBzK9rkiwbqDDA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ny2g2PWLJh6Uh9mEWpa9PxXljYKjgNspRNrDfEDSM+ZDq4cqetbyCEg8?= =?us-ascii?Q?9cDqb8EpwNDdh7iXZOocfJoziByaOmeWj/ylglT4z9o99WtzvXaiVnpqcBqo?= =?us-ascii?Q?ec/s6+fXi8OFXsBw2h4Tb93XshLpehjdQea7evqguzHsmEITi1rbrFT3MaPU?= =?us-ascii?Q?p4AIDWUCKrBKZFW/ZdduMZ87g+c/4cb/jRfQ4RbXAORtirN2d0DJtJLkMm96?= =?us-ascii?Q?kGJM5974JKB1ddx4CSym0A9SucJgi9Uw0LI8o4ZJA6K94goDBDsFpjKl6Pe6?= =?us-ascii?Q?lH8BCS1iAF/YGxqSz+CxeuSx/6GbKlnuoqiNmccOUppzEzkBmPbJjpe57Art?= =?us-ascii?Q?+9ndjvTJBdKWXjBl9hcCwHQoGCmYuMnV1pBllLCpZdb9MY4KcQr0TDDcYZiX?= =?us-ascii?Q?iv7A8Ew+OFfx6JOpV0md6zg34WIp4Kux0CS5IGRGnA1IIxYqm2/oH2K98AzX?= =?us-ascii?Q?9OyWl11WiiJZSkhhYMEX9zzkwIatAvOpth7zQ6rwxRViOSo1fLbP2rlAsHiU?= =?us-ascii?Q?uh/1yFhgMND8nrYmcm2IAmjNV0HLnqYVeFNVs52PqKWZaxuyVWhey4hZVhY4?= =?us-ascii?Q?uj2eZG0qpg=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR18MB4204.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58f52b5d-cfff-420e-e072-08da3819763b X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2022 15:25:23.4695 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Gc9V6IsHOU9hlLWSqYTMQL75wF9bsKldLn9CF530N0vOi8ztfinP3H1HoSxvbsjmmQRgjdMtd1RVle9ZgW3FJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1801MB1975 X-Proofpoint-GUID: GnBrAkAJUOWp6_z2uqOhWR-Z39z1QaZW X-Proofpoint-ORIG-GUID: GnBrAkAJUOWp6_z2uqOhWR-Z39z1QaZW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-17_03,2022-05-17_02,2022-02-23_01 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 Hi Zhichao, Can you please add the same API for freebsd also. Thanks Harman > -----Original Message----- > From: zhichaox.zeng@intel.com > Sent: Tuesday, May 17, 2022 9:35 PM > To: dev@dpdk.org; qiming.yang@intel.com > Cc: Zhichao Zeng ; Harman Kalra > > Subject: [EXT] [DPDK] eal/linux: fix segfaults due to thread exit order >=20 > External Email >=20 > ---------------------------------------------------------------------- > From: Zhichao Zeng >=20 > The eal-intr-thread is not closed before exiting the main thread. There i= s a > small probability that when the eal-intr-thread is about to use some poin= ters, > the pointers were just released in the process of exiting, which cause th= e > segment fault error caught by ASan. >=20 > Close the eal-intr-thread before exiting the mian thread to avoid segment > fault. >=20 > Signed-off-by: Zhichao Zeng > --- > lib/eal/common/eal_private.h | 7 +++++++ > lib/eal/linux/eal.c | 1 + > lib/eal/linux/eal_interrupts.c | 12 ++++++++++++ > 3 files changed, 20 insertions(+) >=20 > diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h > index 44d14241f0..7adf41b7d7 100644 > --- a/lib/eal/common/eal_private.h > +++ b/lib/eal/common/eal_private.h > @@ -152,6 +152,13 @@ int rte_eal_tailqs_init(void); > */ > int rte_eal_intr_init(void); >=20 > +/** > + * Destroy interrupt handling thread. > + * > + * This function is private to EAL. > + */ > +void rte_eal_intr_destroy(void); > + > /** > * Close the default log stream > * > diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index > 1ef263434a..b310681acf 100644 > --- a/lib/eal/linux/eal.c > +++ b/lib/eal/linux/eal.c > @@ -1266,6 +1266,7 @@ rte_eal_cleanup(void) > vfio_mp_sync_cleanup(); > #endif > rte_mp_channel_cleanup(); > + rte_eal_intr_destroy(); > /* after this point, any DPDK pointers will become dangling */ > rte_eal_memory_detach(); > eal_mp_dev_hotplug_cleanup(); > diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupt= s.c > index d52ec8eb4c..b246b87273 100644 > --- a/lib/eal/linux/eal_interrupts.c > +++ b/lib/eal/linux/eal_interrupts.c > @@ -1199,6 +1199,18 @@ rte_eal_intr_init(void) > return ret; > } >=20 > +void > +rte_eal_intr_destroy(void) > +{ > + /* cancel the host thread */ > + pthread_cancel(intr_thread); > + pthread_join(intr_thread, NULL); > + > + /* close the pipe used by epoll */ > + close(intr_pipe.writefd); > + close(intr_pipe.readfd); > +} > + > static void > eal_intr_proc_rxtx_intr(int fd, const struct rte_intr_handle *intr_handl= e) { > -- > 2.25.1