[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commits] r19873 - in /fsf/trunk/libc: ChangeLog nptl/ChangeLog nptl/tst-pthread-getattr.c sysdeps/sparc/fpu/libm-test-ulps



Author: eglibc
Date: Sun Jul 29 00:01:41 2012
New Revision: 19873

Log:
Import glibc-mainline for 2012-07-29

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/nptl/ChangeLog
    fsf/trunk/libc/nptl/tst-pthread-getattr.c
    fsf/trunk/libc/sysdeps/sparc/fpu/libm-test-ulps

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun Jul 29 00:01:41 2012
@@ -1,3 +1,7 @@
+2012-07-27  David S. Miller  <davem@xxxxxxxxxxxxx>
+
+	* sysdeps/sparc/fpu/libm-test-ulps: Update.
+
 2012-07-27  Gary Benson  <gbenson@xxxxxxxxxx>
 
 	[BZ #14298]

Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Sun Jul 29 00:01:41 2012
@@ -1,3 +1,14 @@
+2012-07-28  Siddhesh Poyarekar  <siddhesh@xxxxxxxxxx>
+
+	* tst-pthread-getattr.c (MAX_STACK_SIZE): New macro.
+	(pagesize): New static variable.
+	(allocate_and_test): Return MEM.  Rename parameter to TARGET.
+	(check_stack_top): New local variables MEM and PAGEMASK.  Cap
+	stack size to MAX_STACK_SIZE.  Call allocate_and_test for
+	halfway up the stack top page.  Verify that the top page was
+	written into.
+	(do_test): Get pagesize using sysconf.
+
 2012-07-25  Andreas Schwab  <schwab@xxxxxxxxxxxxxx>
 
 	* sysdeps/unix/sysv/linux/i386/pt-vfork.S: Remove pseudo_end

Modified: fsf/trunk/libc/nptl/tst-pthread-getattr.c
==============================================================================
--- fsf/trunk/libc/nptl/tst-pthread-getattr.c (original)
+++ fsf/trunk/libc/nptl/tst-pthread-getattr.c Sun Jul 29 00:01:41 2012
@@ -21,18 +21,37 @@
 #include <stdio.h>
 #include <string.h>
 #include <sys/resource.h>
+#include <sys/param.h>
 #include <pthread.h>
 #include <alloca.h>
+#include <assert.h>
+#include <unistd.h>
+#include <inttypes.h>
 
-/* Move the stack pointer so that stackaddr is accessible and then check if it
-   really is accessible.  This will segfault if it fails.  */
-static void
-allocate_and_test (void *stackaddr)
+/* There is an obscure bug in the kernel due to which RLIMIT_STACK is sometimes
+   returned as unlimited when it is not, which may cause this test to fail.
+   There is also the other case where RLIMIT_STACK is intentionally set as
+   unlimited or very high, which may result in a vma that is too large and again
+   results in a test case failure.  To avoid these problems, we cap the stack
+   size to one less than 8M.  See the following mailing list threads for more
+   information about this problem:
+   <http://sourceware.org/ml/libc-alpha/2012-06/msg00599.html>
+   <http://sourceware.org/ml/libc-alpha/2012-06/msg00713.html>.  */
+#define MAX_STACK_SIZE (8192 * 1024 - 1)
+
+static size_t pagesize;
+
+/* Check if the page in which TARGET lies is accessible.  This will segfault
+   if it fails.  */
+static volatile char *
+allocate_and_test (char *target)
 {
-  void *mem = &mem;
-  /* FIXME:  The difference will be negative for _STACK_GROWSUP.  */
-  mem = alloca ((size_t) (mem - stackaddr));
-  *(int *)(mem) = 0;
+  volatile char *mem = (char *) &mem;
+  /* FIXME:  mem >= target for _STACK_GROWSUP.  */
+  mem = alloca ((size_t) (mem - target));
+
+  *mem = 42;
+  return mem;
 }
 
 static int
@@ -42,13 +61,13 @@
   int ret;
   pthread_t me = pthread_self ();
 
-  if ((ret = pthread_getattr_np (me, &attr)))
+  if ((ret = pthread_getattr_np (me, &attr)) < 0)
     {
       printf ("%s: pthread_getattr_np failed: %s\n", id, strerror (ret));
       return 1;
     }
 
-  if ((ret = pthread_attr_getstack (&attr, stackaddr, stacksize)))
+  if ((ret = pthread_attr_getstack (&attr, stackaddr, stacksize)) < 0)
     {
       printf ("%s: pthread_attr_getstack returned error: %s\n", id,
 	      strerror (ret));
@@ -65,8 +84,10 @@
 {
   struct rlimit stack_limit;
   void *stackaddr;
+  volatile void *mem;
   size_t stacksize = 0;
   int ret;
+  uintptr_t pagemask = ~(pagesize - 1);
 
   puts ("Verifying that stack top is accessible");
 
@@ -77,19 +98,22 @@
       return 1;
     }
 
+  printf ("current rlimit_stack is %zu\n", (size_t) stack_limit.rlim_cur);
+
   if (get_self_pthread_attr ("check_stack_top", &stackaddr, &stacksize))
     return 1;
 
-  /* Reduce the rlimit to a page less that what is currently being returned so
-     that we ensure that pthread_getattr_np uses rlimit.  The figure is
-     intentionally unaligned so to verify that pthread_getattr_np returns an
-     aligned stacksize that correctly fits into the rlimit.  We don't bother
-     about the case where the stack is limited by the vma below it and not by
-     the rlimit because the stacksize returned in that case is computed from
-     the end of that vma and is hence safe.  */
-  stack_limit.rlim_cur = stacksize - 4095;
-  printf ("Adjusting RLIMIT_STACK to %zu\n", stack_limit.rlim_cur);
-  if ((ret = setrlimit (RLIMIT_STACK, &stack_limit)))
+  /* Reduce the rlimit to a page less that what is currently being returned
+     (subject to a maximum of MAX_STACK_SIZE) so that we ensure that
+     pthread_getattr_np uses rlimit.  The figure is intentionally unaligned so
+     to verify that pthread_getattr_np returns an aligned stacksize that
+     correctly fits into the rlimit.  We don't bother about the case where the
+     stack is limited by the vma below it and not by the rlimit because the
+     stacksize returned in that case is computed from the end of that vma and is
+     hence safe.  */
+  stack_limit.rlim_cur = MIN (stacksize - pagesize + 1, MAX_STACK_SIZE);
+  printf ("Adjusting RLIMIT_STACK to %zu\n", (size_t) stack_limit.rlim_cur);
+  if ((ret = setrlimit (RLIMIT_STACK, &stack_limit)) < 0)
     {
       perror ("setrlimit failed");
       return 1;
@@ -100,7 +124,23 @@
 
   printf ("Adjusted rlimit: stacksize=%zu, stackaddr=%p\n", stacksize,
           stackaddr);
-  allocate_and_test (stackaddr);
+
+  /* A lot of targets tend to write stuff on top of the user stack during
+     context switches, so we cannot possibly safely go up to the very top of
+     stack and test access there.  It is however sufficient to simply check if
+     the top page is accessible, so we target our access halfway up the top
+     page.  Thanks Chris Metcalf for this idea.  */
+  mem = allocate_and_test (stackaddr + pagesize / 2);
+
+  /* Before we celebrate, make sure we actually did test the same page.  */
+  if (((uintptr_t) stackaddr & pagemask) != ((uintptr_t) mem & pagemask))
+    {
+      printf ("We successfully wrote into the wrong page.\n"
+	      "Expected %#" PRIxPTR ", but got %#" PRIxPTR "\n",
+	      (uintptr_t) stackaddr & pagemask, (uintptr_t) mem & pagemask);
+
+      return 1;
+    }
 
   puts ("Stack top tests done");
 
@@ -112,6 +152,7 @@
 static int
 do_test (void)
 {
+  pagesize = sysconf (_SC_PAGESIZE);
   return check_stack_top ();
 }
 

Modified: fsf/trunk/libc/sysdeps/sparc/fpu/libm-test-ulps
==============================================================================
--- fsf/trunk/libc/sysdeps/sparc/fpu/libm-test-ulps (original)
+++ fsf/trunk/libc/sysdeps/sparc/fpu/libm-test-ulps Sun Jul 29 00:01:41 2012
@@ -820,6 +820,9 @@
 ldouble: 1
 
 # clog
+Test "Imaginary part of: clog (-0x1.234566p-40 - 1.0 i) == 5.354083939753840089583620652120903838944e-25 - 1.570796326795931422008642456283782656359 i":
+float: 1
+ifloat: 1
 Test "Real part of: clog (-0x1.fp+127 + 0x1p-149 i) == 88.69109041335841930424871526389807508374 + pi i":
 float: 1
 ifloat: 1
@@ -912,6 +915,9 @@
 Test "Real part of: clog (0x1p-16494 - 0x1.fp+16383 i) == 11356.49165759582936919077408168801636572 - pi/2 i":
 ildouble: 1
 ldouble: 1
+Test "Real part of: clog (1.0 + 0x1.234566p-10 i) == 6.172834701221959432440126967147726538097e-7 + 1.111110564353742042376451655136933182201e-3 i":
+float: 1
+ifloat: 1
 
 # clog10
 Test "Imaginary part of: clog10 (-0 + inf i) == inf + pi/2*log10(e) i":
@@ -952,6 +958,9 @@
 Test "Imaginary part of: clog10 (-0x1p-149 - 0x1.fp+127 i) == 38.51805116050395969095658815123105801479 - 0.6821881769209206737428918127156778851051 i":
 double: 1
 idouble: 1
+Test "Imaginary part of: clog10 (-1.0 + 0x1.234566p-20 i) == 2.556638434669064077889576526006849923281e-13 + 1.364375882602207106407956770293808181427 i":
+double: 1
+idouble: 1
 Test "Real part of: clog10 (-2 - 3 i) == 0.556971676153418384603252578971164214 - 0.937554462986374708541507952140189646 i":
 ildouble: 1
 ldouble: 1
@@ -1009,6 +1018,23 @@
 Test "Imaginary part of: clog10 (0.75 + 1.25 i) == 0.163679467193165171449476605077428975 + 0.447486970040493067069984724340855636 i":
 ildouble: 1
 ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-30 + 1.0 i) == 2.438200411482400072282924063740535840474e-19 + 6.821881764607257184291586401763604544928e-1 i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.234566p-50 + 1.0 i) == 2.217530356103816369479108963807448194409e-31 + 6.821881769209202348667823902864283966959e-1 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-50 + 1.0 i) == 2.217530356103816369479108963807448194409e-31 + 6.821881769209202348667823902864283966959e-1 i":
+float: 1
+ifloat: 1
+Test "Real part of: clog10 (0x1.234566p-60 + 1.0 i) == 2.114801746467415208319767917450504756866e-37 + 6.821881769209206733143018621078368211515e-1 i":
+ildouble: 1
+ldouble: 1
+Test "Imaginary part of: clog10 (0x1.234566p-60 + 1.0 i) == 2.114801746467415208319767917450504756866e-37 + 6.821881769209206733143018621078368211515e-1 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
 Test "Imaginary part of: clog10 (0x1.fffffep+127 + 0x1.fffffep+127 i) == 38.68235441693561449174780668781319348761 + pi/4*log10(e) i":
 double: 1
 float: 1
@@ -1061,6 +1087,33 @@
 float: 1
 idouble: 1
 ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-509 + 1.0 i) == 7.730698388614835910296270976605350994446e-308 + 6.821881769209206737428918127156778851051e-1 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-510 + 1.0 i) == 1.932674597153708977574067744151337748612e-308 + 6.821881769209206737428918127156778851051e-1 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-511 + 1.0 i) == 4.831686492884272443935169360378344371529e-309 + 6.821881769209206737428918127156778851051e-1 i":
+double: 1
+idouble: 1
+Test "Imaginary part of: clog10 (0x1p-61 + 1.0 i) == 4.084085680564517578238994467153626207224e-38 + 6.821881769209206735545466044044889962925e-1 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-62 + 1.0 i) == 1.021021420141129394559748616788406551878e-38 + 6.821881769209206736487192085600834406988e-1 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (0x1p-63 + 1.0 i) == 2.552553550352823486399371541971016379740e-39 + 6.821881769209206736958055106378806629019e-1 i":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+Test "Imaginary part of: clog10 (1.0 + 0x1.234566p-10 i) == 2.680828048441605163181684680300513080769e-7 + 4.825491868832381486767558728169977751564e-4 i":
+double: 1
+idouble: 1
 Test "Imaginary part of: clog10 (3 + inf i) == inf + pi/2*log10(e) i":
 double: 1
 float: 1

_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits