[PATCH] nptl: Add smoke test for pthread_getcpuclockid failure
Florian Weimer
fweimer@redhat.com
Fri Nov 22 11:43:48 GMT 2024
* Siddhesh Poyarekar:
> On 2024-11-22 02:42, Florian Weimer wrote:
>>> +int
>>> +do_test (void)
>>> +{
>>> + pthread_t t = xpthread_create (NULL, thr, NULL);
>>> + xpthread_join (t);
>>> +
>>> + clockid_t c;
>>> + TEST_COMPARE (pthread_getcpuclockid (t, &c), ESRCH);
>> This test is invalid because the lifetime of t has ended. This
>> use-after-free bug becomes visible if you run the test with
>> GLIBC_TUNABLES=glibc.pthread.stack_cache_size=0.
>
> Eek, of course, sorry I should have seen that :/
>
> 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.
Thanks,
Florian
More information about the Libc-alpha
mailing list