about summary refs log tree commit diff
path: root/linuxthreads/attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads/attr.c')
-rw-r--r--linuxthreads/attr.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index a66eb72c27..687334ffdb 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -404,7 +404,11 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 # endif
 #endif
 
+#ifdef USE_TLS
   if (attr->__stackaddr == NULL)
+#else
+  if (descr == &__pthread_initial_thread)
+#endif
     {
       /* Defined in ld.so.  */
       extern void *__libc_stack_end;
@@ -448,6 +452,11 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
 		  attr->__stacksize = rl.rlim_cur;
 		  attr->__stackaddr = (void *) to;
 
+		  /* The limit might be too high.  This is a bogus
+		     situation but try to avoid making it worse.  */
+		  if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr)
+		    attr->__stacksize = (size_t) attr->__stackaddr;
+
 		  /* We succeed and no need to look further.  */
 		  ret = 0;
 		  break;