public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/972] New: pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid
@ 2005-05-26 15:13 torger at ludd dot luth dot se
  2005-05-26 15:17 ` [Bug nptl/972] " jakub at redhat dot com
  0 siblings, 1 reply; 2+ messages in thread
From: torger at ludd dot luth dot se @ 2005-05-26 15:13 UTC (permalink / raw)
  To: glibc-bugs

test program to reproduce the error:
-------------------------

#include <pthread.h>

int
main(void)
{
    struct sched_param dummy_sched;
    int dummy_policy;

    pthread_getschedparam(1010101, &dummy_policy, &dummy_sched);
    
    return 0;
}

------------------------

The problem is that pthread_t is a pointer, and the check if the thread is valid
assumes that the thread is a valid pointer. This may cause a crash not only on
bogus pointers, like in the test programs, but also on already terminated
threads. According to the man page (and standard?), the function should return
ESRCH if the thread id is invalid or has already terminated.

I think that the problem exists in other functions as well, such as
pthread_setschedparam().

This bug was detected in code where pthread_getschedparam() was used to test if
a thread of a given ID existed or not.

-- 
           Summary: pthread_getschedparam() may cause segmentation fault
                    instead of ESRCH if thread id is invalid
           Product: glibc
           Version: 2.3.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: torger at ludd dot luth dot se
                CC: glibc-bugs at sources dot redhat dot com


http://sources.redhat.com/bugzilla/show_bug.cgi?id=972

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug nptl/972] pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid
  2005-05-26 15:13 [Bug nptl/972] New: pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid torger at ludd dot luth dot se
@ 2005-05-26 15:17 ` jakub at redhat dot com
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at redhat dot com @ 2005-05-26 15:17 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2005-05-26 15:17 -------
The standard doesn't say that.
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_getschedparam.html
The standard says that it MAY fail with ESRCH if pthread_t is not valid.
It doesn't with NPTL, but that does not violate the standard.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


http://sources.redhat.com/bugzilla/show_bug.cgi?id=972

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2005-05-26 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-26 15:13 [Bug nptl/972] New: pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid torger at ludd dot luth dot se
2005-05-26 15:17 ` [Bug nptl/972] " jakub 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).