This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #13724] Do not segfault in pthread_setname_np (x, NULL)
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 03 Oct 2013 15:49:38 -0400
- Subject: Re: [PATCH][BZ #13724] Do not segfault in pthread_setname_np (x, NULL)
- Authentication-results: sourceware.org; auth=none
- References: <20131003122009 dot GA8891 at domone dot podge>
On 10/03/2013 08:20 AM, OndÅej BÃlka wrote:
> Hi, this is another bug that could be handled quickly. Problem is if
> pthread_setname_np (x, NULL) should return error code or segfault.
> (see https://sourceware.org/bugzilla/show_bug.cgi?id=13724 )
> If first is desired then following patch does it. If we choose for
> second then close that bugzilla entry.
>
> * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
> Handle null.
>
> diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_setname.c b/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> index d6455dd..45eefa0 100644
> --- a/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> +++ b/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> @@ -34,6 +34,10 @@ pthread_setname_np (th, name)
> {
> const struct pthread *pd = (const struct pthread *) th;
>
> + /* Return EFAULT like pthread_getname_np(x, NULL, 16) does. */
> + if (name == NULL)
> + return EFAULT;
> +
> /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
> macro. So we have to define it here. */
> #define TASK_COMM_LEN 16
>
Thanks for tackling the BZs. You're doing a great job here.
I agree with Jeff Law on this one, this is not a performance
critical routine and checking arguments and returning EFAULT
is good for QoI.
Could you please go one step further and add pthread_setname_np
to the manual? Add a @deftypefun in manual/threads.texi in the
"Non-POSIX Extensions" section and briefly describe the function.
See pthread_getattr_default_np/pthread_setattr_default_np as
exmaples.
OK with manual update.
Note: The manual has a typo and lists pthread_getattr_default_np
twice, the second instance should be pthread_setattr_default_np,
and a fix for that is obvious and can go in immediately.
Cheers,
Carlos.