This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug nptl/972] New: pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid
- From: "torger at ludd dot luth dot se" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 26 May 2005 15:13:27 -0000
- Subject: [Bug nptl/972] New: pthread_getschedparam() may cause segmentation fault instead of ESRCH if thread id is invalid
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
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.