From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 9382C3858C2F; Mon, 22 Jan 2024 09:25:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9382C3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1705915530; bh=OXO6tZTyZVTadzHc6KqB5zzTLPrvk8MnP+0XEpkLRCA=; h=Date:From:To:Subject:Reply-To:References:In-Reply-To:From; b=cKSXBx/Drb4lwadtFf7k2TKE0N8MzRJb1LIcxrfBL7YB4yn+3N1lN+ucUKqlfU+s7 QVkk4jxkQHvW9bG5a/LwiN5HzG9TobvYRKjkWKMMAXkVb8KHTeOWgcCb5PqMpQvgeC xFibR1RHfskZJzHZ5YtipcRllh33BO0RhGApB+tU= Received: by calimero.vinschen.de (Postfix, from userid 500) id 2B9F0A80733; Mon, 22 Jan 2024 10:25:28 +0100 (CET) Date: Mon, 22 Jan 2024 10:25:28 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Possiblly bug of cygwin1.dll Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20240119224436.876a055f356f7c6796bc725b@nifty.ne.jp> <20240120131825.4157c259fe058155137d6fe0@nifty.ne.jp> <20240120141349.cde31e62177a0405b0ee9934@nifty.ne.jp> <87v87ov03x.fsf@Gerda.invalid> <20240120212427.1e69fd3655ece73ecd508def@nifty.ne.jp> <20240121201051.795a4405576a97ab8729e273@nifty.ne.jp> <87fryqizl3.fsf@> <20240122123023.b8eaac0e50d1e8856f44a115@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240122123023.b8eaac0e50d1e8856f44a115@nifty.ne.jp> List-Id: On Jan 22 12:30, Takashi Yano via Cygwin wrote: > PATCH2: (for cygwin) > Avoid handle leak caused when non-static pthread_once_t is initialized > with PTHREAD_ONCE_INIT > diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc > index 7bb4f9fc8..127569160 100644 > --- a/winsup/cygwin/thread.cc > +++ b/winsup/cygwin/thread.cc > @@ -2060,6 +2060,9 @@ pthread::once (pthread_once_t *once_control, void (*init_routine) (void)) > { > init_routine (); > once_control->state = 1; > + pthread_mutex_unlock (&once_control->mutex); > + while (pthread_mutex_destroy (&once_control->mutex) == EBUSY); > + return 0; > } > /* Here we must remove our cancellation handler */ > pthread_mutex_unlock (&once_control->mutex); I see what you're doing here. Wouldn't it be simpler, though, to do this? diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 7bb4f9fc8341..7ec3aace395d 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -2063,6 +2063,7 @@ pthread::once (pthread_once_t *once_control, void (*init_routine) (void)) } /* Here we must remove our cancellation handler */ pthread_mutex_unlock (&once_control->mutex); + while (pthread_mutex_destroy (&once_control->mutex) == EBUSY); return 0; } Corinna