This is the mail archive of the libc-alpha@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]

[PATCH] nptl: add TLS/TCB sizes to requested stack size rather than subtract


From: Ahmad Sharif <asharif@chromium.org>

When Chrome is built with -fprofile-generate, pthread_create() fails
because the TLS size is larger than the stack size requested.  This
is the same issue as reported in bugzilla a while ago.

URL: http://sourceware.org/bugzilla/show_bug.cgi?id=11787
Signed-off-by: Ahmad Sharif <asharif@chromium.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 nptl/ChangeLog       |    7 +++++++
 nptl/allocatestack.c |    6 +++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index ad345f9..6817d97 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2012-03-23  Ahmad Sharif  <asharif@chromium.org>
+
+	[BZ #11787]
+	* allocatestack.c (allocate_stack): Add __static_tls_size to
+	size, and add TLS_TCB_SIZE to size when TLS_TCB_AT_TP is defined.
+	Check attr->stacksize against just MINIMAL_REST_STACK.
+
 2012-03-19  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* sysdeps/x86_64/pthreaddef.h (CURRENT_STACK_FRAME): Use
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 79c4531..4b5998d 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -356,6 +356,10 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
   /* Get the stack size from the attribute if it is set.  Otherwise we
      use the default we determined at start time.  */
   size = attr->stacksize ?: __default_stacksize;
+  size += __static_tls_size;
+#if TLS_TCB_AT_TP
+  size += TLS_TCB_SIZE;
+#endif
 
   /* Get memory for the stack.  */
   if (__builtin_expect (attr->flags & ATTR_FLAG_STACKADDR, 0))
@@ -365,7 +369,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
       /* If the user also specified the size of the stack make sure it
 	 is large enough.  */
       if (attr->stacksize != 0
-	  && attr->stacksize < (__static_tls_size + MINIMAL_REST_STACK))
+	  && attr->stacksize < (MINIMAL_REST_STACK))
 	return EINVAL;
 
       /* Adjust stack size for alignment of the TLS block.  */
-- 
1.7.8.5


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