From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.2.1) Gecko/20030225 Description of problem: pthread_join returns success when joining a thread that has already exitted. It should return ESRCH saying that it could not find the thread. Version-Release number of selected component (if applicable): glibc-2.3.2-27.9 How reproducible: Always Steps to Reproduce: 1. Compile and run the following program: #include <stdio.h> #include <pthread.h> #include <errno.h> void *a_thread_func() { pthread_exit(0); return NULL; } int main(void) { pthread_t new_th; int ret; if (pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { perror("Error creating thread\n"); return 1; } if ( pthread_join(new_th, NULL) !=0 ) { perror("Error in pthread_join()\n"); return 1; } if ( (ret=pthread_join(new_th, NULL)) != ESRCH) { printf("Return code should be ESRCH, but is: %d.\n", ret); return 1; } return 0; } Actual Results: Return code should be ESRCH, but is: 0. Expected Results: No output from the program.
This is ill formed. E.g. POSIX 2001, System Interfaces 2.9.2 allows thread IDs to be reused after pthread_join, essentially what you're trying to do is the same as accessing memory after free on it has been called.