Bug#571639: libc6: pthread_cancel dies screaming if passed an uninitialised pthread_t
Package: libc6
Version: 2.10.2-5
Severity: normal
Hi,
If the equivalent of this happens, then pthread_cancel segfaults:
static pthread_t p;
int main(void)
{
pthread_cancel(p);
}
Culprit would appear to be in pthread_cancel.c:
/* Make sure the descriptor is valid. */
if (INVALID_TD_P (pd))
/* Not a valid thread handle. */
return ESRCH;
Which expands in nptl/pthreadP.h to:
# define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
and Kaboom QED.
SuS would appear to allow us to explode with an 'uninitialised' pthread_t,
or at least doesn't expressly forbid it anywhere I can see, but it would
seem better if we still didn't with a 'default initialised' variable.
I don't really expect this to work in compliant code, so I won't object
if you wontfix or close it, but it surprised me enough to look and point.
Cheers,
Ron
Reply to: