Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 91571 - pthread_join joins exitted thread
pthread_join joins exitted thread
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i586 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2003-05-24 12:17 EDT by Steve Grubb
Modified: 2016-11-24 09:54 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-05-26 06:47:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Steve Grubb 2003-05-24 12:17:58 EDT
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):

How reproducible:

Steps to Reproduce:
1. Compile and run the following program:

#include <stdio.h>
#include <pthread.h>
#include <errno.h>
void *a_thread_func()
        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.
Comment 1 Jakub Jelinek 2003-05-26 06:47:10 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.