aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2023-06-23 00:07:26 +0900
committerTakashi Yano <takashi.yano@nifty.ne.jp>2023-06-23 00:29:30 +0900
commitfcaa1c496768f0781fe7515852ff7dc3bda67e78 (patch)
tree908fce1f9e026bd64904c1695069bbb2ab100af0
parent8c2867eebfa223d761f6f266a6c18b778ed56261 (diff)
downloadnewlib-fcaa1c496768f0781fe7515852ff7dc3bda67e78.zip
newlib-fcaa1c496768f0781fe7515852ff7dc3bda67e78.tar.gz
newlib-fcaa1c496768f0781fe7515852ff7dc3bda67e78.tar.bz2
Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread().
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>
-rw-r--r--winsup/cygwin/thread.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 5c1284a..f614e01 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)