]> gcc.gnu.org Git - gcc.git/commitdiff
gfortran.dg/pr68078.f90: Avoid increasing RLIMIT_AS
authorTobias Burnus <tobias@codesourcery.com>
Thu, 22 Apr 2021 09:05:17 +0000 (11:05 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 22 Apr 2021 09:14:18 +0000 (11:14 +0200)
pr68078.f90 tests out-of-memory handling and calls set_vm_limit to set the
soft limit.  However, setrlimit was then called with hard limit RLIM_INFINITY,
which failed when the current hard limit was lower.

gcc/testsuite/
* gfortran.dg/set_vm_limit.c (set_vm_limit): Call getrlimit, use
obtained hard limit, and only call setrlimit if new softlimit is lower.

gcc/testsuite/gfortran.dg/set_vm_limit.c

index 30c4b43e0ed27b3882981288aa582669e293f8eb..8344f6fd079ef4b13bc258cb495cb2377a00ecd8 100644 (file)
@@ -8,9 +8,20 @@
 void
 set_vm_limit (int vm_limit)
 {
-  struct rlimit rl = { vm_limit, RLIM_INFINITY };
+  struct rlimit rl;
   int r;
 
+  r = getrlimit (RLIMIT_AS, &rl);
+  if (r)
+    {
+      perror ("get_vm_limit");
+      exit (1);
+    }
+
+  if (vm_limit >= rl.rlim_cur)
+    return;
+
+  rl.rlim_cur = vm_limit;
   r = setrlimit (RLIMIT_AS, &rl);
   if (r)
     {
This page took 0.070541 seconds and 5 git commands to generate.