This is the mail archive of the 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] Fix nptl/tst-cond1{6,7} on 32-bit with many cpus

On my machine NR_CPUS=128 and ulimit -s is 8MB.  nptl/tst-cond1{6,7}
tries to create NR_CPUS * 4 threads.

And the amount of stack that tries to allocate is... pretty much the
entire 32-bit address space.

We're just calling one function which invokes some pthread routines.
Therefore using 64K of stack ought to be enough.  Just to be safe
I make sure we use a value which is at least __getpagesize().  At
least on powerpc, sparc, and IA-64 larger default page sizes are

Any objections?


2012-03-25  David S. Miller  <>

	* tst-cond16.c (do_test): Use a thread stack size which is either
	64K or the page size, whichever is larger.

diff --git a/nptl/tst-cond16.c b/nptl/tst-cond16.c
index 44b9863..388acfe 100644
--- a/nptl/tst-cond16.c
+++ b/nptl/tst-cond16.c
@@ -76,9 +76,15 @@ do_test (void)
   count *= 4;
   pthread_t th[count];
-  int i, ret;
+  pthread_attr_t attr;
+  int i, ret, sz;
+  pthread_attr_init (&attr);
+  sz = __getpagesize ();
+  if (sz < 64 * 1024)
+	  sz = 64 * 1024;
+  pthread_attr_setstacksize (&attr, sz);
   for (i = 0; i < count; ++i)
-    if ((ret = pthread_create (&th[i], NULL, tf, NULL)) != 0)
+    if ((ret = pthread_create (&th[i], &attr, tf, NULL)) != 0)
 	errno = ret;
 	printf ("pthread_create %d failed: %m\n", i);

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