[PATCH] nptl: Implement pthread_self in libc.so

Florian Weimer fweimer@redhat.com
Wed Dec 20 07:53:00 GMT 2017


On 12/20/2017 08:16 AM, Carlos O'Donell wrote:

>> The stub implementation is broken, so we can't move more
>> functionality from libpthread to libc until it is fixed anyway.
> 
> That could be fixed for just this case?

You mean, like adding a pthread_t == 0 check to those functions?  I 
think that's the wrong approach.

>   
>>> Are there thread functions we might use in a program not linked against
>>> libpthread e.g. the pthread_atfork changes we have in Fedora?
>>
>> pthread_thread_number_np depends on this change in practical terms.
> 
> Why? In pthread_thread_number_np you can call THREAD_SELF directly?

The function does not call pthread_self, it has a pthread_t argument. 
Its test case crashe with a null pointer dereference if the pthread_self 
change is not applied first.

>>>> The layout of struct pthread_functions is not changed by this commit,
>>>> although the pointer used to store the address of pthread_self is now
>>>> unused.
>>>
>>> Why?
>>
>> To preserve the internal ABI.  It seem to have very little cost.  I
>> can remove the field, of course.
> 
> I would prefer the removal. Please submit a v2.

Please consider the attached patch.

Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pthread_self.patch
Type: text/x-patch
Size: 5682 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171220/b31fc351/attachment.bin>


More information about the Libc-alpha mailing list