From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id C9B1E3858D1E; Mon, 3 Jul 2023 11:03:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9B1E3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688382213; bh=HsKhqLhBr8/me0Yo9S2az7fqykG997WCBwiRpzurgV4=; h=From:To:Subject:Date:From; b=nzwghraG34YVfFzrgueDpB0ojkuEUk0DNN8n6wKm9svNonJVpwoQiN/ckD/L1MT4I I8Q2y7HOxyJ43vMPn0TvXMJokuiPNZlyOsopCEo4eoYBfCho+GbL04SZ/uTGY4MetJ 1hE7uh3aEpQKQDU7WP+JZJkR/JJKsaQiVIMyCQFQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 4c7d0dfec5793cbf5cf3930b91f930479126d8ce X-Git-Newrev: bfb16b0edef49b8e694bcb1b419bfcb5a0a3dfac Message-Id: <20230703110333.C9B1E3858D1E@sourceware.org> Date: Mon, 3 Jul 2023 11:03:33 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dbfb16b0edef= 49b8e694bcb1b419bfcb5a0a3dfac commit bfb16b0edef49b8e694bcb1b419bfcb5a0a3dfac Author: Takashi Yano Date: Fri Jun 23 00:07:26 2023 +0900 Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthre= ad(). =20 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. =20 https://cygwin.com/pipermail/cygwin/2023-June/253792.html =20 With this patch, _my_tls.tid is re-initialized in pthread:: init_mainthread() if it is pthread_null. =20 Reported-by: M=C3=BCmin A. Reviewed-by: Corinna Vinschen Signed-off-by: Takashi Yano Diff: --- 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 =3D _my_tls.tid; - if (!thread) + if (!thread || thread =3D=3D pthread_null::get_null_pthread ()) { thread =3D new pthread (); if (!thread)