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 7E16DA04FD; Tue, 17 May 2022 10:05:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37ACD40042; Tue, 17 May 2022 10:05:02 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 3316B40041 for ; Tue, 17 May 2022 10:04:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652774700; x=1684310700; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+HTAd9fpFzqGSbAzz/pSQl2IfAeuBQsxYizRUsUJQgs=; b=gjzW5x7qNqBELkYL5wBCNAW6osSS3K8k3iKckFVUz0Sqn9Wl480zcHbl PYk8pHkMlCNcV6lof1pt9VceMt5eTMyp6vQX5Ggkiaa2WThenooJosx2D 5X5sYd2R3fnfph9vuCnzvJmyi/LO0k9MF75iVtua+f9+AGfUmOnLNwGHS h0BR8R7gIQgLhxHYq0mZUtI+zZHWVzR2WiWMPGc2SUf1RPvpDTpuqORCt olHvjGyqbBmqC6/hQ/W9YKnfWBgrSnaEy2imefmbnl9lH5yVnZKBL74DW N78i7HjRlgpdpgvze7VR7kpmSFMKYVgIIZTOrE8zRNkeaqirKZ3rG+NU8 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10349"; a="334148943" X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="334148943" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 01:04:59 -0700 X-IronPort-AV: E=Sophos;i="5.91,232,1647327600"; d="scan'208";a="713749596" Received: from unknown (HELO localhost.localdomain) ([10.239.251.103]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 01:04:57 -0700 From: zhichaox.zeng@intel.com To: dev@dpdk.org, qiming.yang@intel.com Cc: Zhichao Zeng , Harman Kalra Subject: [DPDK] eal/linux: fix segfaults due to thread exit order Date: Tue, 17 May 2022 16:04:44 +0000 Message-Id: <20220517160444.413819-1-zhichaox.zeng@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Zhichao Zeng The eal-intr-thread is not closed before exiting the main thread. There is a small probability that when the eal-intr-thread is about to use some pointers, the pointers were just released in the process of exiting, which cause the segment fault error caught by ASan. Close the eal-intr-thread before exiting the mian thread to avoid segment fault. 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(+) 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); +/** + * 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_interrupts.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; } +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_handle) { -- 2.25.1