pthread detach problem with glibc 2.2 on SMP

Wolfram Gloger Wolfram.Gloger@dent.med.uni-muenchen.de
Wed Dec 6 00:45:00 GMT 2000


> The following program compiled with:
> gcc -o pthread-test -g -O2 pthread-test.c -lpthread -Wall
> 
> gives sometimes (try it at least 20 times) on an SMP system as result:
> abc: Interrupted system call
> def: Invalid argument
> 
> with an exit status of 15.  I'm running glibc 2.2 here.

Does the patch below help?

Regards,
Wolfram.

2000-12-06  Wolfram Gloger  <wg@malloc.de>

	* join.c (pthread_detach): Allow case where the thread has already
	terminated.

--- join.c	2000/12/06 08:37:38	1.1
+++ join.c	2000/12/06 08:40:00
@@ -181,11 +181,11 @@
   pthread_descr th;
 
   __pthread_lock(&handle->h_lock, NULL);
-  if (invalid_handle(handle, thread_id)) {
+  th = handle->h_descr;
+  if (th == NULL || th->p_tid != thread_id) {
     __pthread_unlock(&handle->h_lock);
     return ESRCH;
   }
-  th = handle->h_descr;
   /* If already detached, error */
   if (th->p_detached) {
     __pthread_unlock(&handle->h_lock);


More information about the Libc-alpha mailing list