This is the mail archive of the glibc-cvs@sourceware.org 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]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.11-256-g1d78f29


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  1d78f2996dc94c04578e83d1df221811fbe13fc7 (commit)
      from  462a5227b0d3220ab68f65272bd5b9d6d4f49b1f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1d78f2996dc94c04578e83d1df221811fbe13fc7

commit 1d78f2996dc94c04578e83d1df221811fbe13fc7
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Tue Mar 9 20:21:12 2010 -0800

    Fix a few more problem with the recent setxid changes.

diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index fa4c8f2..f51ad43 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-09  Ulrich Drepper  <drepper@redhat.com>
+
+	* pthread_create.c (__pthread_create_2_1): If priorities are incorrect
+	and the call fails wake eventually waiting setxid threads.  Don't free
+	stack here if we try starting a thread.
+	* sysdeps/pthread/createthread.c (do_clone): Only wake setxid waiter
+	if the clone call failed.
+
 2010-03-08  Andreas Schwab  <schwab@redhat.com>
 
 	* pthread_create.c (__pthread_create_2_1): Don't set setxid_futex.
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 14e3cf7..34d83f9 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -537,33 +537,23 @@ __pthread_create_2_1 (newthread, attr, start_routine, arg)
       if (pd->schedparam.sched_priority < minprio
 	  || pd->schedparam.sched_priority > maxprio)
 	{
-	  err = EINVAL;
-	  goto errout;
+	  /* Perhaps a thread wants to change the IDs and if waiting
+	     for this stillborn thread.  */
+	  if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0)
+				== -2, 0))
+	    lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);
+
+	  __deallocate_stack (pd);
+
+	  return EINVAL;
 	}
     }
 
   /* Pass the descriptor to the caller.  */
   *newthread = (pthread_t) pd;
 
-  /* Remember whether the thread is detached or not.  In case of an
-     error we have to free the stacks of non-detached stillborn
-     threads.  */
-  bool is_detached = IS_DETACHED (pd);
-
   /* Start the thread.  */
-  err = create_thread (pd, iattr, STACK_VARIABLES_ARGS);
-  if (err != 0)
-    {
-      /* Something went wrong.  Free the resources.  */
-      if (!is_detached)
-	{
-	errout:
-	  __deallocate_stack (pd);
-	}
-      return err;
-    }
-
-  return 0;
+  return create_thread (pd, iattr, STACK_VARIABLES_ARGS);
 }
 versioned_symbol (libpthread, __pthread_create_2_1, pthread_create, GLIBC_2_1);
 
diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c
index 3bb3915..8d96387 100644
--- a/nptl/sysdeps/pthread/createthread.c
+++ b/nptl/sysdeps/pthread/createthread.c
@@ -75,19 +75,17 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
   int rc = ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags,
 		       pd, &pd->tid, TLS_VALUE, &pd->tid);
 
-  /* Allow setxid from now onwards.  */
-  if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0) == -2, 0))
-    lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);
-
   if (__builtin_expect (rc == -1, 0))
     {
       atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second.  */
 
-      /* Failed.  If the thread is detached, remove the TCB here since
-	 the caller cannot do this.  The caller remembered the thread
-	 as detached and cannot reverify that it is not since it must
-	 not access the thread descriptor again.  */
-      if (IS_DETACHED (pd))
+      /* Perhaps a thread wants to change the IDs and if waiting
+	 for this stillborn thread.  */
+      if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0)
+			    == -2, 0))
+	lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);
+
+      /* Free the resources.  */
 	__deallocate_stack (pd);
 
       /* We have to translate error codes.  */
@@ -120,6 +118,9 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
 	      (void) INTERNAL_SYSCALL (tkill, err2, 2, pd->tid, SIGCANCEL);
 #endif
 
+	      /* We do not free the stack here because the canceled thread
+		 itself will do this.  */
+
 	      return (INTERNAL_SYSCALL_ERROR_P (res, err)
 		      ? INTERNAL_SYSCALL_ERRNO (res, err)
 		      : 0);

-----------------------------------------------------------------------

Summary of changes:
 nptl/ChangeLog                      |    8 ++++++++
 nptl/pthread_create.c               |   30 ++++++++++--------------------
 nptl/sysdeps/pthread/createthread.c |   19 ++++++++++---------
 3 files changed, 28 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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