* [PATCH] Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread().
@ 2023-06-22 15:30 Takashi Yano
2023-07-03 10:39 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Takashi Yano @ 2023-06-22 15:30 UTC (permalink / raw)
To: cygwin-patches; +Cc: Takashi Yano, Mümin A ., Corinna Vinschen
Currently, _my_tls.tid is set to pthread_null if pthread::self()
is called before pthread::init_mainthread(). As a result, pthread::
init_mainthread() does not set _my_tls.tid appropriately. Due to
this, pthread_join() fails in LDAP environment if the program is
the first program which loads cygwin1.dll.
https://cygwin.com/pipermail/cygwin/2023-June/253792.html
With this patch, _my_tls.tid is re-initialized in pthread::
init_mainthread() if it is pthread_null.
Reported-by: Mümin A. <muminaydin06@gmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
winsup/cygwin/thread.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 5c1284a93..f614e01c4 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -364,7 +364,7 @@ void
pthread::init_mainthread ()
{
pthread *thread = _my_tls.tid;
- if (!thread)
+ if (!thread || thread == pthread_null::get_null_pthread ())
{
thread = new pthread ();
if (!thread)
--
2.39.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread().
2023-06-22 15:30 [PATCH] Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread() Takashi Yano
@ 2023-07-03 10:39 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2023-07-03 10:39 UTC (permalink / raw)
To: cygwin-patches
On Jun 23 00:30, Takashi Yano wrote:
> Currently, _my_tls.tid is set to pthread_null if pthread::self()
> is called before pthread::init_mainthread(). As a result, pthread::
> init_mainthread() does not set _my_tls.tid appropriately. Due to
> this, pthread_join() fails in LDAP environment if the program is
> the first program which loads cygwin1.dll.
>
> https://cygwin.com/pipermail/cygwin/2023-June/253792.html
>
> With this patch, _my_tls.tid is re-initialized in pthread::
> init_mainthread() if it is pthread_null.
>
> Reported-by: Mümin A. <muminaydin06@gmail.com>
> Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> ---
> winsup/cygwin/thread.cc | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
> index 5c1284a93..f614e01c4 100644
> --- a/winsup/cygwin/thread.cc
> +++ b/winsup/cygwin/thread.cc
> @@ -364,7 +364,7 @@ void
> pthread::init_mainthread ()
> {
> pthread *thread = _my_tls.tid;
> - if (!thread)
> + if (!thread || thread == pthread_null::get_null_pthread ())
> {
> thread = new pthread ();
> if (!thread)
> --
> 2.39.0
LGTM.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-03 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 15:30 [PATCH] Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread() Takashi Yano
2023-07-03 10:39 ` Corinna Vinschen
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).