This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: pthread detach problem with glibc 2.2 on SMP


> 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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]