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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] __pthread_kill_other_threads_np fix


Hi!

The following testcase (taken from openldap) segfaults with linuxthreads
since 2001-01-08. Fix attached.

#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

static void *task(void *p)
{
  sleep(30);
  return NULL;
}

int
main()
{
  pthread_t t;
  int status;

  status = pthread_create(&t, NULL, task, NULL);
  if(status)
    exit(status);

  status = pthread_detach(t);
  pthread_kill_other_threads_np();
  return status;
}


2001-01-13  Jakub Jelinek  <jakub@redhat.com>

	* pthread.c (pthread_onexit_process): Clear
	__pthread_manager_thread_bos after freeing it.
	(__pthread_reset_main_thread): Only free
	__pthread_manager_thread_bos if not yet freed.

--- linuxthreads/pthread.c.jj	Fri Jan 12 11:41:56 2001
+++ linuxthreads/pthread.c	Sat Jan 13 14:02:52 2001
@@ -753,6 +753,7 @@ static void pthread_onexit_process(int r
       {
 	waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
 	free (__pthread_manager_thread_bos);
+	__pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
       }
   }
 }
@@ -845,8 +846,11 @@ void __pthread_reset_main_thread()
 
   if (__pthread_manager_request != -1) {
     /* Free the thread manager stack */
-    free(__pthread_manager_thread_bos);
-    __pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
+    if (__pthread_manager_thread_bos != NULL)
+      {
+	free(__pthread_manager_thread_bos);
+	__pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
+      }
     /* Close the two ends of the pipe */
     __libc_close(__pthread_manager_request);
     __libc_close(__pthread_manager_reader);

	Jakub

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