public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/13724] New: pthread_setname_np segfault
@ 2012-02-22 19:06 law at redhat dot com
  2012-02-23  1:32 ` [Bug nptl/13724] " yselkowitz at cygwin dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: law at redhat dot com @ 2012-02-22 19:06 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

             Bug #: 13724
           Summary: pthread_setname_np segfault
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: unassigned@sourceware.org
        ReportedBy: law@redhat.com
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


pthread_setname_np can segfault if passed a NULL pointer.

#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <string.h>

int
main(void)
{
  pthread_t thr = pthread_self ();
  int ret = pthread_setname_np (thr, NULL);
  printf ("pthread_setname_np: %s\n", strerror (ret));
  return 0;
}

The setname_np/getname_np have non-null attributes for the appropriate
arguments and one could make a case that this is ultimately a user error. 
However, given these are not performance critical routines, I believe we can
spare the cycles to do argument verification  to improve the quality of
implementation.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
@ 2012-02-23  1:32 ` yselkowitz at cygwin dot com
  2012-02-23  3:05 ` yselkowitz at cygwin dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: yselkowitz at cygwin dot com @ 2012-02-23  1:32 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

Cygwin/X maintainer <yselkowitz at cygwin dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yselkowitz at cygwin dot
                   |                            |com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
  2012-02-23  1:32 ` [Bug nptl/13724] " yselkowitz at cygwin dot com
@ 2012-02-23  3:05 ` yselkowitz at cygwin dot com
  2012-02-23  7:11 ` jakub at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: yselkowitz at cygwin dot com @ 2012-02-23  3:05 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

--- Comment #1 from Cygwin/X maintainer <yselkowitz at cygwin dot com> 2012-02-23 03:04:44 UTC ---
Since pthread_setname_np is undocumented, I'm not sure what the desired
solution is in this case:

1) Return EFAULT, just as pthread_getname_np (thr, NULL, 16).
2) Leave the nonnull attribute but treat NULL as "" just in case.
3) Remove the nonnull attribute and allow NULL as synonym for "".

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
  2012-02-23  1:32 ` [Bug nptl/13724] " yselkowitz at cygwin dot com
  2012-02-23  3:05 ` yselkowitz at cygwin dot com
@ 2012-02-23  7:11 ` jakub at redhat dot com
  2012-02-23  7:26 ` yselkowitz at cygwin dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at redhat dot com @ 2012-02-23  7:11 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

Jakub Jelinek <jakub at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com

--- Comment #2 from Jakub Jelinek <jakub at redhat dot com> 2012-02-23 07:09:57 UTC ---
When it isn't documented in man pages or info pages, the headers are the only
documentation.  And the headers clearly document that you must not call it with
NULL:

/* Get thread name visible in the kernel and its interfaces.  */
extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
                               size_t __buflen)
     __THROW __nonnull ((2));

/* Set thread name visible in the kernel and its interfaces.  */
extern int pthread_setname_np (pthread_t __target_thread, __const char *__name)
     __THROW __nonnull ((2));

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
                   ` (2 preceding siblings ...)
  2012-02-23  7:11 ` jakub at redhat dot com
@ 2012-02-23  7:26 ` yselkowitz at cygwin dot com
  2012-02-23 10:02 ` schwab@linux-m68k.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: yselkowitz at cygwin dot com @ 2012-02-23  7:26 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

--- Comment #3 from Cygwin/X maintainer <yselkowitz at cygwin dot com> 2012-02-23 07:25:39 UTC ---
(In reply to comment #2)
> When it isn't documented in man pages or info pages, the headers are the only
> documentation.  And the headers clearly document that you must not call it with
> NULL:

I understand that, but that doesn't necessarily mean it should segfault if NULL
is passed anyway.  pthread_getname_np(thr, NULL, 16) returns EFAULT, but
pthread_setname_np(thr, NULL) segfaults.  That inconsistency in a corresponding
pair of functions seems odd to me, hence the question if this is the intended
result.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
                   ` (3 preceding siblings ...)
  2012-02-23  7:26 ` yselkowitz at cygwin dot com
@ 2012-02-23 10:02 ` schwab@linux-m68k.org
  2013-10-08 14:56 ` neleai at seznam dot cz
  2014-06-26 15:20 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2012-02-23 10:02 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=13724

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> 2012-02-23 10:01:49 UTC ---
It's consistently undefined behaviour.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
                   ` (4 preceding siblings ...)
  2012-02-23 10:02 ` schwab@linux-m68k.org
@ 2013-10-08 14:56 ` neleai at seznam dot cz
  2014-06-26 15:20 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: neleai at seznam dot cz @ 2013-10-08 14:56 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13724

Ondrej Bilka <neleai at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |neleai at seznam dot cz
         Resolution|---                         |WONTFIX

--- Comment #5 from Ondrej Bilka <neleai at seznam dot cz> ---
In discussion at http://www.sourceware.org/ml/libc-alpha/2013-10/msg00111.html
we decided that crashing is better as error code will likely be ignored.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug nptl/13724] pthread_setname_np segfault
  2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
                   ` (5 preceding siblings ...)
  2013-10-08 14:56 ` neleai at seznam dot cz
@ 2014-06-26 15:20 ` fweimer at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: fweimer at redhat dot com @ 2014-06-26 15:20 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=13724

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-26 15:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-22 19:06 [Bug nptl/13724] New: pthread_setname_np segfault law at redhat dot com
2012-02-23  1:32 ` [Bug nptl/13724] " yselkowitz at cygwin dot com
2012-02-23  3:05 ` yselkowitz at cygwin dot com
2012-02-23  7:11 ` jakub at redhat dot com
2012-02-23  7:26 ` yselkowitz at cygwin dot com
2012-02-23 10:02 ` schwab@linux-m68k.org
2013-10-08 14:56 ` neleai at seznam dot cz
2014-06-26 15:20 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).