[PATCH] nptl: Add smoke test for pthread_getcpuclockid failure

Siddhesh Poyarekar siddhesh@sourceware.org
Fri Nov 22 12:02:34 GMT 2024


On 2024-11-22 06:53, Florian Weimer wrote:
> * Siddhesh Poyarekar:
> 
>> On 2024-11-22 06:43, Florian Weimer wrote:
>>>> I can't see a way to intercept points within the lifetime of the
>>>> thread id where tid is <=0, but I'll send an update if I do.
>>> You could avoid joining the thread t and loop until
>>> pthread_getcpuclockid fails, and then check that the error is ESRCH.
>>
>> That would mean considering a timeout as success as well, wouldn't it?
>> Or put in an upper limit to iterations.
> 
> I believe the kernel will reset the TID to zero once the thread exits.

Yes, but the main thread will need to win the race to see the TID before 
the thread descriptor is invalidated.

In fact, I wonder if we can even ensure that the main thread sees into 
only a valid (but not freed) thread descriptor.  If we can't ensure 
that, why go through the pain of the race anyway?  Wouldn't it be easier 
to put in a comment in this test saying that it's technically invalid, 
but we're using internal knowledge to test a path that cannot otherwise 
be reasonably tested?

thanks,
Sid


More information about the Libc-alpha mailing list