Blame SOURCES/glibc-rh771342.patch

4999bf
2011-06-30  Ulrich Drepper  <drepper@gmail.com>
4999bf
4999bf
	* nptl-init.c (__nptl_set_robust): New function.
4999bf
	(pthread_functions): Add reference.
4999bf
	* npthreadP.h: Declare __nptl_set_robust.
4999bf
	* sysdeps/pthread/pthread-functions.h (pthread_functions): Add
4999bf
	ptr_set_robust member.
4999bf
	* sysdeps/unix/sysv/linux/fork.c: Call set_robust_list syscall in
4999bf
	child if threads are used.
4999bf
4999bf
diff -Nrup a/nptl/nptl-init.c b/nptl/nptl-init.c
4999bf
--- a/nptl/nptl-init.c	2011-12-20 00:29:54.645538691 -0700
4999bf
+++ b/nptl/nptl-init.c	2012-01-03 10:18:38.977513783 -0700
4999bf
@@ -69,6 +69,13 @@ extern void __libc_setup_tls (size_t tcb
4999bf
 #endif
4999bf
 
4999bf
 #ifdef SHARED
4999bf
+static
4999bf
+#else
4999bf
+extern
4999bf
+#endif
4999bf
+void __nptl_set_robust (struct pthread *);
4999bf
+
4999bf
+#ifdef SHARED
4999bf
 static void nptl_freeres (void);
4999bf
 
4999bf
 
4999bf
@@ -131,13 +138,25 @@ static const struct pthread_functions pt
4999bf
     .ptr__nptl_deallocate_tsd = __nptl_deallocate_tsd,
4999bf
     .ptr__nptl_setxid = __nptl_setxid,
4999bf
     /* For now only the stack cache needs to be freed.  */
4999bf
-    .ptr_freeres = nptl_freeres
4999bf
+    .ptr_freeres = nptl_freeres,
4999bf
+    .ptr_set_robust = __nptl_set_robust
4999bf
   };
4999bf
 # define ptr_pthread_functions &pthread_functions
4999bf
 #else
4999bf
 # define ptr_pthread_functions NULL
4999bf
 #endif
4999bf
 
4999bf
+#ifdef SHARED
4999bf
+static
4999bf
+#endif
4999bf
+void
4999bf
+__nptl_set_robust (struct pthread *self)
4999bf
+{
4999bf
+  INTERNAL_SYSCALL_DECL (err);
4999bf
+  INTERNAL_SYSCALL (set_robust_list, err, 2, &self->robust_head,
4999bf
+                   sizeof (struct robust_list_head));
4999bf
+}
4999bf
+
4999bf
 
4999bf
 #ifdef SHARED
4999bf
 /* This function is called indirectly from the freeres code in libc.  */
4999bf
diff -Nrup a/nptl/pthreadP.h b/nptl/pthreadP.h
4999bf
--- a/nptl/pthreadP.h	2010-05-04 05:27:23.000000000 -0600
4999bf
+++ b/nptl/pthreadP.h	2012-01-03 10:12:35.599269269 -0700
4999bf
@@ -555,17 +555,20 @@ extern void __pthread_cleanup_pop_restor
4999bf
 
4999bf
 /* Old cleanup interfaces, still used in libc.so.  */
4999bf
 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
4999bf
-                                   void (*routine) (void *), void *arg);
4999bf
+				   void (*routine) (void *), void *arg);
4999bf
 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
4999bf
-                                  int execute);
4999bf
+				  int execute);
4999bf
 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
4999bf
-                                         void (*routine) (void *), void *arg);
4999bf
+					 void (*routine) (void *), void *arg);
4999bf
 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
4999bf
-                                          int execute);
4999bf
+					  int execute);
4999bf
 
4999bf
 extern void __nptl_deallocate_tsd (void) attribute_hidden;
4999bf
 
4999bf
 extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
4999bf
+#ifndef SHARED
4999bf
+extern void __nptl_set_robust (struct pthread *self);
4999bf
+#endif
4999bf
 
4999bf
 extern void __free_stacks (size_t limit) attribute_hidden;
4999bf
 
4999bf
diff -Nrup a/nptl/sysdeps/pthread/pthread-functions.h b/nptl/sysdeps/pthread/pthread-functions.h
4999bf
--- a/nptl/sysdeps/pthread/pthread-functions.h	2010-05-04 05:27:23.000000000 -0600
4999bf
+++ b/nptl/sysdeps/pthread/pthread-functions.h	2012-01-03 10:12:35.639269301 -0700
4999bf
@@ -97,6 +97,7 @@ struct pthread_functions
4999bf
   void (*ptr__nptl_deallocate_tsd) (void);
4999bf
   int (*ptr__nptl_setxid) (struct xid_command *);
4999bf
   void (*ptr_freeres) (void);
4999bf
+  void (*ptr_set_robust) (struct pthread *);
4999bf
 };
4999bf
 
4999bf
 /* Variable in libc.so.  */
4999bf
diff -Nrup a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c
4999bf
--- a/nptl/sysdeps/unix/sysv/linux/fork.c	2010-05-04 05:27:23.000000000 -0600
4999bf
+++ b/nptl/sysdeps/unix/sysv/linux/fork.c	2012-01-03 10:12:35.649269309 -0700
4999bf
@@ -29,6 +29,7 @@
4999bf
 #include <ldsodefs.h>
4999bf
 #include <bits/stdio-lock.h>
4999bf
 #include <atomic.h>
4999bf
+#include <pthreadP.h>
4999bf
 
4999bf
 
4999bf
 unsigned long int *__fork_generation_pointer;
4999bf
@@ -86,8 +87,8 @@ __libc_fork (void)
4999bf
 	 just go away.  The unloading code works in the order of the
4999bf
 	 list.
4999bf
 
4999bf
-         While executing the registered handlers we are building a
4999bf
-         list of all the entries so that we can go backward later on.  */
4999bf
+	 While executing the registered handlers we are building a
4999bf
+	 list of all the entries so that we can go backward later on.  */
4999bf
       while (1)
4999bf
 	{
4999bf
 	  /* Execute the handler if there is one.  */
4999bf
@@ -154,6 +155,24 @@ __libc_fork (void)
4999bf
       GL(dl_cpuclock_offset) = now;
4999bf
 #endif
4999bf
 
4999bf
+#ifdef __NR_set_robust_list
4999bf
+      /* Initialize the robust mutex list which has been reset during
4999bf
+	 the fork.  We do not check for errors since if it fails here
4999bf
+	 it failed at process start as well and noone could have used
4999bf
+	 robust mutexes.  We also do not have to set
4999bf
+	 self->robust_head.futex_offset since we inherit the correct
4999bf
+	 value from the parent.  */
4999bf
+# ifdef SHARED
4999bf
+      if (__libc_pthread_functions.ptr_set_robust != NULL)
4999bf
+	PTHFCT_CALL (ptr_set_robust, (self));
4999bf
+# else
4999bf
+      extern __typeof (__nptl_set_robust) __nptl_set_robust
4999bf
+	__attribute__((weak));
4999bf
+      if (__builtin_expect (__nptl_set_robust != NULL, 0))
4999bf
+	__nptl_set_robust (self);
4999bf
+# endif
4999bf
+#endif
4999bf
+
4999bf
       /* Reset the file list.  These are recursive mutexes.  */
4999bf
       fresetlockfiles ();
4999bf
 
4999bf
@@ -170,10 +189,10 @@ __libc_fork (void)
4999bf
 	    allp->handler->child_handler ();
4999bf
 
4999bf
 	  /* Note that we do not have to wake any possible waiter.
4999bf
- 	     This is the only thread in the new process.  The count
4999bf
- 	     may have been bumped up by other threads doing a fork.
4999bf
- 	     We reset it to 1, to avoid waiting for non-existing
4999bf
- 	     thread(s) to release the count.  */
4999bf
+	     This is the only thread in the new process.  The count
4999bf
+	     may have been bumped up by other threads doing a fork.
4999bf
+	     We reset it to 1, to avoid waiting for non-existing
4999bf
+	     thread(s) to release the count.  */
4999bf
 	  allp->handler->refcntr = 1;
4999bf
 
4999bf
 	  /* XXX We could at this point look through the object pool