From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.linux.lib.musl.general/22183 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Zhang, Huilin (Rebecca) (CN)" Newsgroups: gmane.linux.lib.musl.general Subject: RE: [PATCH] __libc_exit_fini forgets to do pthread_mutex_unlock Date: Thu, 3 Jul 2025 01:44:16 +0000 Message-ID: References: <20250702022854.30301-1-rebecca.zhang.cn@windriver.com> <20250702143321.GI1827@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11994"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "musl@lists.openwall.com" , "Deng, Wenbin (CN)" To: Rich Felker , Markus Wichmann Original-X-From: musl-return-22203-gllmg-musl=m.gmane-mx.org@lists.openwall.com Thu Jul 03 03:51:21 2025 Return-path: Envelope-to: gllmg-musl@m.gmane-mx.org Original-Received: from second.openwall.net ([193.110.157.125]) by ciao.gmane.io with smtp (Exim 4.92) (envelope-from ) id 1uX96e-00032H-Tv for gllmg-musl@m.gmane-mx.org; Thu, 03 Jul 2025 03:51:20 +0200 Original-Received: (qmail 3478 invoked by uid 550); 3 Jul 2025 01:51:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: x-ms-reactions: disallow Original-Received: (qmail 30257 invoked from network); 3 Jul 2025 01:44:35 -0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BteBKbJHSfyQ45wKSvLhnQU/poGlVDju5gC/G9XJa/01oQjJ88vPS3xVM90TUsCfGCogwJaddY/YGZufCTD0O9qm0x/vWi2IssME7FrGzyfdCany3KBCM3SuhO5juRgwf5V0/aFZXFU+EO21M3uTB/qNl6WSlF2R2AaudaPj5/eL3QxGDItwaZHC4dDSpfoHCjTgQZzKwaFjxqYQ2xkMECHNmtvHCQei4UCCXm9F6K8U3JcZwA6YPuhTp5LwftnCIdZXpUO5I7sZnNYn5TkuwqWojO8BiM8UDSzEfGeVykmtcf9CNNO5I/PYTmqmuQokWN+VL9vRc8hVby92ndDLcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=QahlL5ogy1om4qOmNNQdekBJ+ZwC10n2tfAlMbk7h/g=; b=YL6pDDeOp4aQyveqyIUZsK4TFSiHE/fW31fMUTuODDbsHaV0oX2zvZ93VTFiVc83/LPBilk7Xo/AEtAfEB4SLFzuGx25rirYXkUNDggQVBZRgdaMX9KPSVQkqm9BHa7KWBZ3IkeGGBDNgvNZma/ZrZmAiNbLsDyxlqobyIe6ZGUoiw45mlQmhax22hnhUGWNM6ALFnBGProhz+TyR16UJqGVHin11k7qDkUB1m4swKn4aguBqLLBjB7c2uMiqhRHDcJG2yWEz8rKl6KYUjBvVbutyBklvHo3i8UO0mPZrKWZxWqL1LUxm2qZD0KGKJcIJWG+DTcK6ZVlJzLQPDmFgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Thread-Topic: [musl] [PATCH] __libc_exit_fini forgets to do pthread_mutex_unlock Thread-Index: AQHb6vkSfH2H46WN9UiLo+0rKBhaFrQePiaAgACobICAALc2YA== In-Reply-To: <20250702143321.GI1827@brightrain.aerifal.cx> Accept-Language: en-US Content-Language: en-US x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV3PR11MB8743:EE_|DS4PPF409BB8CE8:EE_ x-ms-office365-filtering-correlation-id: 2b5df7b3-f8cd-49c5-2a3b-08ddb9d31eb8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|1800799024|376014|366016|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?QwsWkKgDvvFeq8YQ/YHND439nRpF2B8lyKl/2m6BqJchNOpt3cBW4HoxZdSD?= =?us-ascii?Q?Orzm5spxI/bGX+6/q7UnSgQcLHFbpmjrd1lzyNH+Ondx8tjifAH5QHHHlERK?= =?us-ascii?Q?16+uDeQohlAmtAA5bCqMngJfPxFytD9hNvsLpgnjYofEI+mvnyRvUFqQtYZ0?= =?us-ascii?Q?MjPytp+uFKa7ZWsU30TRhdhhhj5FCiRAwooHQpQlFHaGzXC73WCjotEri5Ys?= =?us-ascii?Q?FGo5tq7t5rG5REcRO2GIZsIK+r6g6NxSQooGyMa3AOrtNXQCGYgwaPyHjMSj?= =?us-ascii?Q?65TtanV4OwAoRIQcAe/3UhLU67Ytc5etlIATerp0KyugkCEDU5AN3B0IUGeW?= =?us-ascii?Q?YvzAevyV0eyN5wQ/m0RCS9EXBZQATQX67PMoTiMh4TnSBZdxsyqqdCduGJXS?= =?us-ascii?Q?BkU91xBv0t6lA0jEnI6UnlThwt/oSVYAJFHdPzZPoPt9c+7XchacHbrgycbP?= =?us-ascii?Q?40FaKZpuG1xTyYefBv16+yOUAseoU/8PL4oucD/LHkbQVE0H04O+gAN0o6PG?= =?us-ascii?Q?XUBwb1Nu8JG4BaKW7Uca6dIdGjANFd1Y5JviUt9SPETQg1BtbJsfU8DeIaZN?= =?us-ascii?Q?8yCWzk/ZbR3gHmRotGBqivtll2uz39F2szLt5pxFFsZaoPy20d6qhrdipPnp?= =?us-ascii?Q?uAE0O x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV3PR11MB8743.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?e/BAfIhCzCbOWdazHBblrIbiBMe9Kos0eByXKUQe6d4U+Cz5uEuJ8Djn9V88?= =?us-ascii?Q?KxNabDg2o6F79HP0kB0ud+79tiOE3qwPBic0+uPhgvErtUvoy7m9io2Smeqb?= =?us-ascii?Q?59ZXpHtRpNiZINFE3uBdqa2A3wf150mtp4QBzB1FnnGOnXUhAl9fkkjq57nC?= =?us-ascii?Q?Qyf5wGqI0hcVLmnKuCphS5iincgwsfUl2TMIP9zDsiFMEBE1F0Tv76AI2Fk6?= =?us-ascii?Q?ocZfdboW763Mbf0/oU0hUS4dKcyNt8PKhXMhgvuyvlAtKFM+n/vOECNtqHSJ?= =?us-ascii?Q?Kzclos3AbXRiRe9j/PAOQiwoHuYNDDgqUjsTWckPztzkK/D2zFrRMIXp3GuE?= =?us-ascii?Q?3Xl5CKB50Wys8hBgHDb/EiTzcuBpNLETIMgFSgrCAVYg1NV9icWIxSaqPwHt?= =?us-ascii?Q?kXA7tG068JP1wS8UBRHyb7vCwZPL2uW/V5vh0QBltaSEB4qdG+z51jXMG55X?= =?us-ascii?Q?mt9QHR000MVedKqBPiiMJOByBHljNEOzg33VWkdOnOV/VQOag4VYOCEkgXNa?= =?us-ascii?Q?DOO0jTTjGhQKmndg3YQ+A5s4oSIiuOe4vrEfiB7rsgwwyzqPPhVW2Dk3DkNw?= =?us-ascii?Q?fQ9Z2N+JiuuZa9GbkGuwO9T3Go886xDlIlKCiZE9vgcvpMq5GA3JeptDDFXY?= =?us-ascii?Q?GU X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV3PR11MB8743.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b5df7b3-f8cd-49c5-2a3b-08ddb9d31eb8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2025 01:44:16.0803 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fBMwWKx3jHSaWccAxhr2FxoRj79A9YsuhqAGtVYVCy+foYdoioBT+QNI4nnb/YIIUPXAZRX8kSWBpVJ/Nsta1nisLSBoToz0l9pXCPPzOeo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PPF409BB8CE8 X-Authority-Analysis: v=2.4 cv=LPRmQIW9 c=1 sm=1 tr=0 ts=6865e073 cx=c_pps a=Pyh3CA1es36lNkRVDm3xrw==:117 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=Wb1JkmetP80A:10 a=hAG5_4vcAAAA:8 a=VVlED5B4AAAA:8 a=XkRKQH6RAAAA:8 a=t7CeM3EgAAAA:8 a=yj-aMKAYKbz0kkd27lYA:9 a=CjuIK1q_8ugA:10 a=8Bh8Pg2EFav9IBZ9i9Tn:22 a=1gUyE30hU_ULiMxJiLUW:22 a=FdTzh2GWekK77mhwV6Dw:22 X-Proofpoint-GUID: E9OlFKQTOGkISi59trA4yfe04sErYVd9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzAzMDAxMSBTYWx0ZWRfXwgz+O17UWAGI vdKkrFNxvfJjy7XjZGn46/LFSnugKWy/9G8noXW8xYkChiHMXSnts91K1fLYEtjrsRI0sjektRl Al2RkCPa9wUewuztlTWSWtlxAsQaPxj6JU4rKBp5bhZCO3AQzD60bCOVqXipm2Z9UlLNGMlZYjk Rl9DJEAWcQaX3GJrLLXeVNLuULt+eBhTD2G+5tbWDzlPlNhmcMUjv/y3zJFjl/s5OiiZBzNoIkf q37Z8I6cZyA3P8YFz9v5hPYZu8IOcZMq2Ah0fAmtB+vltgnRRncuW7SDNXCISZSWUkf0DZ24OMJ IGfKtAA0ZrWEFju79xCjy3XSkXYDL8nsaD2ZgE1nRrmOCYo1T3/6lXcMBW5v0A/TxN80k/OoJ7p UWqAsDNEeQrms0h6afcHdL1QAfIQM4bqWn+ElL+eSiSoHIiUwRazzSpyrCb4CCb+4PjcmL+m X-Proofpoint-ORIG-GUID: E9OlFKQTOGkISi59trA4yfe04sErYVd9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.7,FMLib:17.12.80.40 definitions=2025-07-03_01,2025-07-02_04,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1011 mlxlogscore=999 phishscore=0 impostorscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.21.0-2505280000 definitions=main-2507030011 Xref: news.gmane.io gmane.linux.lib.musl.general:22183 Archived-At: Hello, Rich, Markus, Thanks for your explanation.=20 Yes, if we change "exit" to "_exit", the test case could exit normally. OK, we accept it is really a deliberate omission. Thanks, Rebecca -----Original Message----- From: Rich Felker =20 Sent: Wednesday, July 2, 2025 10:33 PM To: Markus Wichmann Cc: musl@lists.openwall.com; Zhang, Huilin (Rebecca) (CN) ; Deng, Wenbin (CN) Subject: Re: [musl] [PATCH] __libc_exit_fini forgets to do pthread_mutex_un= lock CAUTION: This email comes from a non Wind River email account! Do not click links or open attachments unless you recognize the sender and = know the content is safe. On Wed, Jul 02, 2025 at 06:30:33AM +0200, Markus Wichmann wrote: > Am Wed, Jul 02, 2025 at 10:28:54AM +0800 schrieb rebecca.zhang.cn@windriv= er.com: > > From: Rebecca Zhang > > > > This commit fixes the issue that __libc_exit_fini only do=20 > > pthread_mutex_lock, but forget to do pthread_mutex_unlock. > > --- > > ldso/dynlink.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/ldso/dynlink.c b/ldso/dynlink.c index ceca3c9..7885675=20 > > 100644 > > --- a/ldso/dynlink.c > > +++ b/ldso/dynlink.c > > @@ -1492,6 +1492,7 @@ void __libc_exit_fini() > > fpaddr(p, dyn[DT_FINI])(); #endif > > } > > + pthread_mutex_unlock(&init_fini_lock); > > } > > > > void __ldso_atfork(int who) > > -- > > 2.34.1 > > > I think that is a deliberate omision. __libc_exit_fini() is called on=20 > process exit. After it runs, it must not run again, and no new=20 > initializer must run at all. The process will exit very soon anyway.=20 > The only way to deadlock here is if a destructor calls exit(), which=20 > they aren't allowed to do. It is very much deliberate that this lock is never released. Similarly with= a number of other locks they did not seem to notice that would cause the s= ame behavior even if this one was changed. The general pattern is "a contra= ctual requirement of exit is that all things of category X have finished be= fore the process terminates", and this necessitates ensuring that no new "t= hings of category X" can come into existence once you're past the step wher= e they're processed. Other examples include flushing stdio (must not allow any new data to becom= e buffered after flush is complete) and processing atexit handlers (must no= t allow a new handler to be registered after the loop that runs them). Rich