public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: pthread: Fix handle leak in pthread_once.
@ 2024-01-24 14:44 Takashi Yano
0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2024-01-24 14:44 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2c5433e5da8216aaf7458e50c63683c68fb0d3e8
commit 2c5433e5da8216aaf7458e50c63683c68fb0d3e8
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Wed Jan 24 22:33:12 2024 +0900
Cygwin: pthread: Fix handle leak in pthread_once.
If pthread_once() is called with pthread_once_t initialized using
PTREAD_ONCE_INIT, pthread_once does not release pthread_mutex used
internally. This patch fixes that by calling pthread_mutex_destroy()
in the thread which has called init_routine.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diff:
---
winsup/cygwin/thread.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 7bb4f9fc8..0f8327831 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-24 14:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24 14:44 [newlib-cygwin] Cygwin: pthread: Fix handle leak in pthread_once Takashi Yano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).