about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-11-28 22:27:20 +0000
committerUlrich Drepper <drepper@redhat.com>2001-11-28 22:27:20 +0000
commitcf6a2367e82ba5b322baf0fc0caa5d57e799c72d (patch)
tree6231ff95b897d8af2428dbe041a30ad022acd35a
parent4e735c9aaf9e05a1d4f587f5b049b2f515ff755a (diff)
downloadglibc-cf6a2367e82ba5b322baf0fc0caa5d57e799c72d.tar.gz
glibc-cf6a2367e82ba5b322baf0fc0caa5d57e799c72d.tar.xz
glibc-cf6a2367e82ba5b322baf0fc0caa5d57e799c72d.zip
Update.
2001-11-22  Wolfram Gloger  <wg@malloc.de>

	* pthread.c (pthread_onexit_process): Don't call free
	after threads have been asynchronously terminated.

	* manager.c (pthread_handle_exit): Surround cancellation
	of threads with __flockfilelist()/__funlockfilelist().
-rw-r--r--linuxthreads/ChangeLog8
-rw-r--r--linuxthreads/manager.c7
-rw-r--r--linuxthreads/pthread.c4
3 files changed, 18 insertions, 1 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index b6aa503b0b..307388b6f6 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,11 @@
+2001-11-22  Wolfram Gloger  <wg@malloc.de>
+
+	* pthread.c (pthread_onexit_process): Don't call free
+	after threads have been asynchronously terminated.
+
+	* manager.c (pthread_handle_exit): Surround cancellation
+	of threads with __flockfilelist()/__funlockfilelist().
+
 2001-11-26  Andreas Schwab  <schwab@suse.de>
 
 	* manager.c (pthread_handle_create): Start the child thread with
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index c8808197c1..0872146e3f 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -909,6 +909,12 @@ static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
   pthread_descr th;
   __pthread_exit_requested = 1;
   __pthread_exit_code = exitcode;
+  /* A forced asynchronous cancellation follows.  Make sure we won't
+     get stuck later in the main thread with a system lock being held
+     by one of the cancelled threads.  Ideally one would use the same
+     code as in pthread_atfork(), but we can't distinguish system and
+     user handlers there.  */
+  __flockfilelist();
   /* Send the CANCEL signal to all running threads, including the main
      thread, but excluding the thread from which the exit request originated
      (that thread must complete the exit, e.g. calling atexit functions
@@ -925,6 +931,7 @@ static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
        th = th->p_nextlive) {
     waitpid(th->p_pid, NULL, __WCLONE);
   }
+  __fresetlockfiles();
   restart(issuing_thread);
   _exit(0);
 }
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index b287dc8d03..81261416e2 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -795,7 +795,9 @@ static void pthread_onexit_process(int retcode, void *arg)
     if (self == __pthread_main_thread)
       {
 	waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE);
-	free (__pthread_manager_thread_bos);
+	/* Since all threads have been asynchronously terminated
+           (possibly holding locks), free cannot be used any more.  */
+	/*free (__pthread_manager_thread_bos);*/
 	__pthread_manager_thread_bos = __pthread_manager_thread_tos = NULL;
       }
   }