public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: [Patch, committed] gfortran.dg/pr68078.f90: Avoid increasing RLIMIT_AS
Date: Thu, 22 Apr 2021 11:18:21 +0200	[thread overview]
Message-ID: <21214aca-e098-c582-91d5-1cba52a1e2b0@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

The test did fail when the virtual memory already had a hard limit !=
unlimited.

Committed as r12-57-gfaf7d413a3f3337be1a3ac5cdf33e0e3b87b426e

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 1205 bytes --]

commit faf7d413a3f3337be1a3ac5cdf33e0e3b87b426e
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.

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)
     {

                 reply	other threads:[~2021-04-22  9:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=21214aca-e098-c582-91d5-1cba52a1e2b0@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).