From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 547C53853800; Thu, 27 May 2021 23:48:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 547C53853800 From: "hpa at zytor dot com" To: glibc-bugs@sourceware.org Subject: [Bug nptl/27880] Please provide a pthread pid accessor Date: Thu, 27 May 2021 23:48:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: nptl X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hpa at zytor dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: adhemerval.zanella at linaro dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2021 23:48:08 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27880 --- Comment #11 from hpa at zytor dot com --- As far as a pthread_id being reused - it doesn't seem to be fundamentally different from what can happen with any other use of pthread_id? It is actu= ally a pointer, so it isn't any different from any other stale pointer? It really seems to be absolutely no difference to me: if an old pthread_id = can be reused and this causing failures, then *any* of the pthread functions are affected. In the case of (2), this actually makes it a bit safer than what the pthrea= ds interface currently provides: at least there is a second thing to test (the= tid is at least likely to change.) When a pthread is detached from its underlying kernel thread, this should return zero or -1 with ESRCH; and as you correctly point out this is pretty much exactly what your INVALID_NOT_TERMINATED_TD_P() test does... If this kind of robustness is an issue, you really can't just use a plain pointer, but this is really unrelated to this specific use case; you would probably need to do something like a {table index, generation number} token. The MacOS interface does seem a bit needlessly complicated; pid_t pthread_gettid_np(pthread_t thread) is definitely simpler. --=20 You are receiving this mail because: You are on the CC list for the bug.=