Bug#253303: libc6 nptl cond wait and cacelation bug
Package: libc6
Version: 2.3.2.ds1-13
See attached program. It hangs with kernel 2.6.7-rc2. According to this link it
depends on bug in glibc:
http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=108631
Debian glibc is poisioned too still.
--
Lukáš Hejtmánek
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
static pthread_mutex_t gbl_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t gbl_condv = PTHREAD_COND_INITIALIZER;
void waitThread_cleanup(void *arg)
{
int rc;
rc = pthread_mutex_unlock(&gbl_mutex);
assert(rc == 0);
return;
}
void * waitThread(void *arg)
{
int rc;
pthread_cleanup_push(waitThread_cleanup, NULL);
rc = pthread_mutex_lock(&gbl_mutex);
assert(rc == 0);
/* wait until this thread is canceled */
while (1 == 1) {
rc = pthread_cond_wait(&gbl_condv, &gbl_mutex);
assert(rc == 0);
}
/* this routine never reaches this point */
rc = pthread_mutex_unlock(&gbl_mutex);
assert(rc == 0);
pthread_cleanup_pop(0);
return NULL;
}
main (int argc, char *argv[])
{
int i, rc;
pthread_t wait_tid;
for (i = 0; i < 1000000; i++)
{
fprintf(stderr, "loop %d
", i);
rc = pthread_create(&wait_tid, NULL, waitThread, NULL);
assert(rc == 0);
rc = pthread_cancel(wait_tid);
assert(rc == 0);
rc = pthread_join(wait_tid, NULL);
assert(rc == 0);
}
return;
}
Reply to: