X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DA563858C2F
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1705922192;
	bh=srH9HLIWuo+EPWP/J3ueABTCd/NY3P6LVbDlnyDJmgQ=;
	h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=t7FcNZoBd0kgg+81IRgbNr8Ik7os2HIk67elKbBLvRUsPaWVpN1twtncTBtiF0JDc
	 iv4qa2FNMlpRMvCPFlkoi4dAytZ9uu8SQPWV/9yz+9XBUfdOfn2Dkz0tKwOFRFzT/T
	 62RpzzKkft29sm4m/sFl3OHjvODbcpW6BFdX7Frg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54D993858D20
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 54D993858D20
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705922167; cv=none;
 b=PsMERVg2wLD0yFhfa3qip4TEhiR3dUQukmkbAkmYPQTU1iAahVMgfJectP7k2hta1fNTAKA8qIXRp9zgnV2mm4VPGSyHzchef9k/7jwcG3AEHTIFGFK2zDrgKHNKPUVl1n5tS8ckbhVu3Htvwt6ZoYCzdilM6EGqent8Qi0XZqM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1705922167; c=relaxed/simple;
 bh=WZMargytj5pWkyxQjfGNvu2h7X/v7gaWFO5zqtvkxlo=;
 h=Date:From:To:Subject:Message-Id:Mime-Version;
 b=L2w+yyIwy8F9ClVCYZRSfe1gNV21tbkIk2jIMuLZIRJ3TksKFxysot0c3s2SN2B4O/NKVW3mKe1WxW8cKuw45nrMd/IwLWc7mniNyZHfvQfzSw5csMzImiU0ovXVYXk81OM1ZTl15UM6gFm87NW0QKEiN202UAauy+dBpSRlk24=
ARC-Authentication-Results: i=1; server2.sourceware.org
Date: Mon, 22 Jan 2024 20:16:02 +0900
To: cygwin@cygwin.com
Subject: Re: Possiblly bug of cygwin1.dll
Message-Id: <20240122201602.0a172f5965821f6e8d6afb96@nifty.ne.jp>
In-Reply-To: <Za48HKcCwgYSLQdY@calimero.vinschen.de>
References: <20240119224436.876a055f356f7c6796bc725b@nifty.ne.jp>
 <ZaqHGElhXZIc3NFX@calimero.vinschen.de>
 <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>
 <Za40iEPcedfBSt5n@calimero.vinschen.de>
 <Za48HKcCwgYSLQdY@calimero.vinschen.de>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0,
 KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS,
 TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Takashi Yano via Cygwin <cygwin@cygwin.com>
Reply-To: Takashi Yano <takashi.yano@nifty.ne.jp>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On Mon, 22 Jan 2024 10:57:48 +0100
Corinna Vinschen wrote:
> On Jan 22 10:25, Corinna Vinschen via Cygwin wrote:
> > 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 */
> 
> Strange enough, this comment accompanies the code since its inception
> in 2001.  It says explicitly "remove" the cancellation handler.
> That sounds like the idea was right, just the programmer forgot about
> it afterwards...

I am not sure what 'cancellation handler' means here. Is it the
event handler in pthread_mutex_t?

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
