Re: [PATCH v2] pthread_detach_1-2: Fix failure on modern glibc

Martin Doucha <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
On 6/12/26 04:05, Wei Gao wrote:
> On Thu, Jun 11, 2026 at 05:33:31PM +0200, Martin Doucha wrote:
>> Hi,
>> this looks like trying to hide a glibc bug to me. I've looked at both the
>> POSIX standard and Linux man pages and there is no mention that already
>> exited threads may be left joinable. I think we should report this as a bug
>> and wait for response from glibc maintainers.
> 
> I think is actually not a glibc bug, but correct behavior under POSIX.
> 
> Link: The Open Group - pthread_detach (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_detach.html)
> 
> Wording:
> 1)Under the DESCRIPTION section, it explicitly states:
>      > "The behavior is undefined if the value specified by the thread argument to pthread_detach() does not refer to a joinable thread."

Every thread that was created as joinable remains joinable until one of 
two things happens:
1) It gets joined by pthread_join(). In this case, the thread handle 
becomes invalid.
2) It gets detached by pthread_detach().

If a thread has already exited before it got detached, it is still 
joinable, otherwise pthread_join() would be fundamentally broken.

But POSIX issue 7 has also changed the specification of errors for 
pthread_join() and calling it on invalid thread handle is now undefined 
behavior. I think we should drop the test entirely, the scenario is no 
longer valid according to the latest POSIX.

-- 
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.