This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

3.1.1 PATCH: Properly set resource limits in libstdc++ v3 testsuite


As reported by Kaveh,

	http://gcc.gnu.org/ml/gcc/2002-05/msg00255.html

there are a couple of additional libstdc++ v3 testsuite failures on IRIX
6.2 compared to 6.5:

> 7.  libstdc++-v3 failures on irix6.2 beyond those that appear on 6.5.
>     FAIL: 21_strings/ctor_copy_dtor.cc execution test
>     FAIL: 21_strings/insert.cc execution test
>     FAIL: 27_io/ios_base_storage.cc execution test
>     No solution yet.

The first two of them are due to a generic testsuite bug:

Linking the testcases with libmalloc_ss from speedshop, one sees that all
calls to malloc fail on IRIX 6.2:

SSmalloc error (Process 7693): malloc(1280) returned NULL pointer
SSmalloc error (Process 7693): malloc(84) returned NULL pointer
SSmalloc error (Process 7693): malloc(80) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(192) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(3528) returned NULL pointer
SSmalloc error (Process 7693): malloc(80) returned NULL pointer
SSmalloc error (Process 7693): malloc(80) returned NULL pointer
SSmalloc error (Process 7693): malloc(192) returned NULL pointer
Abort

After some poking around, I noticed that before those calls to malloc,
there are four calls to setrlimit which behave differently on IRIX 6.2 and
6.5: on 6.2, the first three succeed:

   63mS setrlimit(RLIMIT_DATA, 0x7ffb7e78) OK
   63mS setrlimit(RLIMIT_RSS, 0x7ffb7e78) OK
   63mS setrlimit(RLIMIT_VMEM, 0x7ffb7e78) OK
   63mS setrlimit(RLIMIT_VMEM, 0x7ffb7e78) errno = 1 (Operation not permitted)

while on IRIX 6.5 both using the 6.2 binary and a 6.5 binary all four calls
fail with EINVAL:

  709mS[  0]                 : setrlimit(RLIMIT_DATA, 0x7ffb7e78) errno = 22 (Invalid argument)
  709mS[  0]                 : setrlimit(RLIMIT_RSS, 0x7ffb7e78) errno = 22 (Invalid argument)
  709mS[  0]                 : setrlimit(RLIMIT_VMEM, 0x7ffb7e78) errno = 22 (Invalid argument)
  709mS[  0]                 : setrlimit(RLIMIT_VMEM, 0x7ffb7e78) errno = 22 (Invalid argument)

Since there are no resource limits in place on IRIX 6.5, all calls to
malloc and thus the testcase succeeds.

This is most likely due to the fact that the rlim_max member of struct
rlimit was never initialized before the calls to setrlimit, but takes any
value that happens to be on the stack.  I suppose that this leads to hard
limits below the soft limit (which should be rejected by the kernel with
EINVAL, but isn't on IRIX 6.2) and the observed malloc failures.  The
proper fix is to retrieve the old limits with getrlimit before calling
setrlimit with the new soft limits installed.

Tested by re-running make check in libstdc++-v3/testsuite on
mips-sgi-irix6.2: it fixes exactly those two testcases (the only ones using
__set_testsuite_memlimit).

Ok for mainline (and 3.1.1 after the branch is unfrozen)?

	Rainer


Tue May 14 02:08:47 2002  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* testsuite/testsuite_hooks.h (__set_testsuite_memlimit): Retrieve
	current limits before setting.

Index: testsuite_hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.h,v
retrieving revision 1.5
diff -u -p -r1.5 testsuite_hooks.h
--- testsuite_hooks.h	17 Jan 2002 23:37:43 -0000	1.5
+++ testsuite_hooks.h	14 May 2002 10:40:10 -0000
@@ -81,25 +81,33 @@ void
 __set_testsuite_memlimit(float __size = MEMLIMIT_MB)
 {
     struct rlimit r;
-    r.rlim_cur = (rlim_t)(__size * 1048576);
+    rlim_t limit = (rlim_t)(__size * 1048576);
 
     // Heap size, seems to be common.
 #if _GLIBCPP_HAVE_MEMLIMIT_DATA
+    getrlimit(RLIMIT_DATA, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_DATA, &r);
 #endif
 
     // Resident set size.
 #if _GLIBCPP_HAVE_MEMLIMIT_RSS
+    getrlimit(RLIMIT_RSS, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_RSS, &r);
 #endif
 
     // Mapped memory (brk + mmap).
 #if _GLIBCPP_HAVE_MEMLIMIT_VMEM
+    getrlimit(RLIMIT_VMEM, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_VMEM, &r);
 #endif
 
     // Virtual memory.
 #if _GLIBCPP_HAVE_MEMLIMIT_AS
+    getrlimit(RLIMIT_AS, &r);
+    r.rlim_cur = limit;
     setrlimit(RLIMIT_AS, &r);
 #endif
 }


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