Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 20 Sep 2015 20:07:28 +0200
From: Julien Ramseier <>
Subject: pthread_join stuck in infinite loop


pthread_join() never returns when calling it on a detached thread.
I would expect it to return EINVAL instead.

Here’s a small test case:

#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>

void *world_thd(void *arg) {
	return NULL;

int main() {
	int ret;
	pthread_t thd;
	pthread_attr_t attr;

	if (pthread_attr_init(&attr))
		return 1;
	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
		return 1;
	if (pthread_create(&thd, &attr, world_thd, NULL)) 
		return 1;

	ret = pthread_join(thd, NULL);
	if (ret == EINVAL)
		printf("Thread is not joinable\n");
	else {
		fprintf(stderr, "Failed to join thread: %i\n", ret);
		return 1;

	return 0;


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.