public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8280] gfortran.dg/pr68078.f90: Avoid increasing RLIMIT_AS
@ 2021-04-22 10:30 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-04-22 10:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3d8c8b6146ac8998204be818cbb36ff9f7a2fa6e

commit r11-8280-g3d8c8b6146ac8998204be818cbb36ff9f7a2fa6e
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu Apr 22 11:05:17 2021 +0200

    gfortran.dg/pr68078.f90: Avoid increasing RLIMIT_AS
    
    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.
    
    (cherry picked from commit faf7d413a3f3337be1a3ac5cdf33e0e3b87b426e)

Diff:
---
 gcc/testsuite/gfortran.dg/set_vm_limit.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/set_vm_limit.c b/gcc/testsuite/gfortran.dg/set_vm_limit.c
index 30c4b43e0ed..8344f6fd079 100644
--- a/gcc/testsuite/gfortran.dg/set_vm_limit.c
+++ b/gcc/testsuite/gfortran.dg/set_vm_limit.c
@@ -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)
     {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-22 10:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 10:30 [gcc r11-8280] gfortran.dg/pr68078.f90: Avoid increasing RLIMIT_AS Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).