From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021202 Description of problem: Threads fail to cancel at sem_wait() on rh9, glibc 2.3.2-27.9. The symptom is that the thread fails to join after it is cancelled on a sem_wait(). If the example program is executed from bash and is suspended (via ctrl-Z) and resumed (via a "fg"), it cancels correctly. Code example supplied works on rh8.0 always, and rh9 under the following circumstances: 1) Custom built kernel (stock linux 2.4.21 from kernel.org) 2) if the following environmental variable (and value) exists LD_ASSUME_KERNEL=2.4.19 The code fragment was compiled as fiollows: gcc -Wall -ansi-pedantic pthreads-test.c -o pthreads-test -lpthread ------------------------------------ pthreads-test.c ------------------------------------------------- #include <semaphore.h> #include <pthread.h> #include <stdio.h> #include <unistd.h> sem_t sem; void *thread( void *stuff ) { while(1) { sem_wait(&sem); printf("Burp\n"); } } int main(int argc, char* argv[]) { pthread_t t1; pthread_attr_t t1_attr; pthread_attr_init(&t1_attr); void *retval; pthread_attr_setdetachstate(&t1_attr, PTHREAD_CREATE_JOINABLE); sem_init(&sem,0,0); pthread_create(&t1, &t1_attr, &thread, 0); /* Make sure the thread is waiting at the semaphore */ sleep(1); sem_post(&sem); /* Must burp here and wait on the sem_wait in the thread */ sleep(1); /* Thread must be at the semaphore now, so cancel it. */ pthread_cancel(t1); printf("Waiting for thread to join\n"); pthread_join(t1,&retval); /* If we don't get here, the thread did not cancel. Press ctrl-Z and type BG, and it will cancel then. Weird. */ printf("OK. sem_wait() is a cancellation point.\n"); return 0; } --------------------------------------------------------- end --------------------------------------- Version-Release number of selected component (if applicable): linux version 2.4.20-18.9 How reproducible: Always Steps to Reproduce: 1. Buiild code fragment in teh description and execute it 2. Note that it fails to report "OK. sem_wait() is a cancellation point" 3. If in bash, suspend using crtl-Z, and start using "fg". Note that it now cancells Actual Results: ./pthreads-test Start Burp Expected Results: ./pthreads-test Burp Waiting for thread to join OK. sem_wait() is a cancellation point. Additional info: It is related to bugs 86416 and 89601. This report provides a small C program that reproduces the problem.