This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
PATCH: Do not use RLIMIT_AS on HP-UX
- From: Mark Mitchell <mark at codesourcery dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org, zack at codesourcery dot com
- Date: Sat, 21 Feb 2004 12:54:34 -0800
- Subject: PATCH: Do not use RLIMIT_AS on HP-UX
- Reply-to: mark at codesourcery dot com
This patch prevents us from using RLIMIT_AS on HP-UX. RLIMIT_AS has
some odd behavior on HP-UX. In particular, any smallish limit results
in a total refusal to dynamically allocate memory.
I ran this program:
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int try_limit (rlim_t lim) {
struct rlimit r;
if (getrlimit (RLIMIT_AS, &r) == -1)
perror ("could not get soft limit");
r.rlim_cur = lim;
if (setrlimit (RLIMIT_AS, &r) == -1)
perror ("could not set soft limit");
void *p = malloc (1000);
fprintf (stderr, "%ld: %s\n", lim, p ? "yes" : "no");
if (p)
free (p);
return p != 0;
}
int main () {
rlim_t lim = 16 * 1024 * 1024;
while (!try_limit (lim))
lim *= 2;
}
on HP-UX 11.23 and found that in 32-bit mode, malloc did not succeed
with a limit less than about 128MB, and in 64-bit mode, malloc did not
succeed with a limit less than 512MB.
This patch fixes a number of spurious failures on HP-UX 11.23.
Tested on ia64-hp-hpux11.23, installed on the mainline and on the 3.4
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-02-21 Mark Mitchell <mark@codesourcery.com>
* testsuite/testsuite_hooks.cc (__gnu_test::set_memory_limits): Do
not set RLIMIT_AS on HP-UX.
Index: testsuite_hooks.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.cc,v
retrieving revision 1.19
diff -c -5 -p -r1.19 testsuite_hooks.cc
*** testsuite_hooks.cc 16 Jan 2004 08:43:45 -0000 1.19
--- testsuite_hooks.cc 21 Feb 2004 20:31:51 -0000
*************** namespace __gnu_test
*** 72,82 ****
r.rlim_cur = limit;
setrlimit(RLIMIT_VMEM, &r);
#endif
// Virtual memory.
! #if _GLIBCXX_HAVE_MEMLIMIT_AS
getrlimit(RLIMIT_AS, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_AS, &r);
#endif
}
--- 72,85 ----
r.rlim_cur = limit;
setrlimit(RLIMIT_VMEM, &r);
#endif
// Virtual memory.
! // On HP-UX 11.23, a trivial C++ program that sets RLIMIT_AS to
! // anything less than 128MB cannot "malloc" even 1K of memory.
! // Therefore, we skip RLIMIT_AS on HP-UX.
! #if _GLIBCXX_HAVE_MEMLIMIT_AS && !defined(__hpux__)
getrlimit(RLIMIT_AS, &r);
r.rlim_cur = limit;
setrlimit(RLIMIT_AS, &r);
#endif
}