public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc: Bernhard Reutner-Fischer via Fortran <fortran@gcc.gnu.org>,
	gcc-patches@gcc.gnu.org, Harald Anlauf <anlauf@gmx.de>,
	Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
Subject: Re: ping Re: [PATCH 3/3] Fortran: Fix mpz and mpfr memory leaks
Date: Mon, 8 May 2023 08:00:03 +0200	[thread overview]
Message-ID: <20230508080003.79d0e408@nbbrfq> (raw)
In-Reply-To: <ZD3FsyFy+afsp1Dp@troutmask.apl.washington.edu>

On Mon, 17 Apr 2023 15:18:27 -0700
Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> On Mon, Apr 17, 2023 at 09:47:50PM +0200, Bernhard Reutner-Fischer via Fortran wrote:
> > On Mon, 03 Apr 2023 23:42:06 +0200
> > Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> >   
> > > On 3 April 2023 21:50:49 CEST, Harald Anlauf <anlauf@gmx.de> wrote:  
> > > >Hi Bernhard,
> > > >
> > > >there is neither context nor a related PR with a testcase showing
> > > >that this patch fixes issues seen there.    
> > > 
> > > Yes, i forgot to mention the PR:
> > > 
> > > PR fortran/68800
> > > 
> > > I did not construct individual test cases but it should be obvious that we should not leak these.
> > >   
> > > >
> > > >On 4/2/23 17:05, Bernhard Reutner-Fischer via Gcc-patches wrote:    
> > > >> From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>
> > > >> 
> > > >> Cc: fortran@gcc.gnu.org
> > > >> 
> > > >> gcc/fortran/ChangeLog:
> > > >> 
> > > >> 	* array.cc (gfc_ref_dimen_size): Free mpz memory before ICEing.
> > > >> 	* expr.cc (find_array_section): Fix mpz memory leak.
> > > >> 	* simplify.cc (gfc_simplify_reshape): Fix mpz memory leaks in
> > > >> 	error paths.
> > > >> 	(gfc_simplify_set_exponent): Fix mpfr memory leak.
> > > >> ---
> > > >>   gcc/fortran/array.cc    | 3 +++
> > > >>   gcc/fortran/expr.cc     | 8 ++++----
> > > >>   gcc/fortran/simplify.cc | 7 ++++++-
> > > >>   3 files changed, 13 insertions(+), 5 deletions(-)
> > > >> 
> > > >> diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
> > > >> index be5eb8b6a0f..8b1e816a859 100644
> > > >> --- a/gcc/fortran/array.cc
> > > >> +++ b/gcc/fortran/array.cc
> > > >> @@ -2541,6 +2541,9 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end)
> > > >>         return t;
> > > >> 
> > > >>       default:
> > > >> +      mpz_clear (lower);
> > > >> +      mpz_clear (stride);
> > > >> +      mpz_clear (upper);
> > > >>         gfc_internal_error ("gfc_ref_dimen_size(): Bad dimen_type");
> > > >>       }    
> > > >
> > > >  What is the point of clearing variables before issuing
> > > >  a gfc_internal_error?    
> > > 
> > > To make it obvious that we are aware that we allocated these.  
> 
> I must admit I agree with Harald on this portion
> of the diff.  What's the point?  There is alot more
> allocated than just those 3 mzp_t variables when the
> internal error occurs.  For example, gfortran does not
> walk the namespaces and free those before the ICE.
> I suppose silencing valgrind might be sufficient 
> reason for the clutter.  So, ok.

I've dropped this hunk and pushed the rest as r14-567-g2521390dd2f8e5
Harald fixed the leak of expr in gfc_simplify_set_exponent in the
meantime.
thanks,

  reply	other threads:[~2023-05-08  6:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 10:11 [PATCH] [RFC] RAII auto_mpfr and autp_mpz Richard Biener
2023-03-06 10:44 ` Jonathan Wakely
2023-03-06 11:01   ` Richard Biener
2023-03-06 11:03     ` Jonathan Wakely
2023-03-06 11:10     ` Jakub Jelinek
2023-03-06 11:29       ` Richard Biener
2023-03-07 18:51         ` Bernhard Reutner-Fischer
2023-03-07 19:03           ` Jakub Jelinek
2023-04-02 15:05         ` [PATCH 0/3] Fix mpfr and mpz memory leaks Bernhard Reutner-Fischer
2023-04-02 15:05         ` [PATCH 1/3] go: Fix memory leak in Integer_expression Bernhard Reutner-Fischer
2023-04-02 15:05         ` [PATCH 2/3] rust: Fix memory leak in compile_{integer,float}_literal Bernhard Reutner-Fischer
2023-04-02 15:05         ` [PATCH 3/3] Fortran: Fix mpz and mpfr memory leaks Bernhard Reutner-Fischer
2023-04-03 19:50           ` Harald Anlauf
2023-04-03 19:50             ` Harald Anlauf
2023-04-03 21:42             ` Bernhard Reutner-Fischer
2023-04-17 19:47               ` ping " Bernhard Reutner-Fischer
2023-04-17 22:18                 ` Steve Kargl
2023-05-08  6:00                   ` Bernhard Reutner-Fischer [this message]
2023-03-07 19:15     ` [PATCH] [RFC] RAII auto_mpfr and autp_mpz Alexander Monakov
2023-03-07 21:35       ` Jonathan Wakely
2023-03-07 21:51         ` Alexander Monakov
2023-03-07 21:54           ` Jonathan Wakely
2023-03-07 21:59             ` Marek Polacek
2023-03-08  7:25           ` Richard Biener
2023-03-08 10:13             ` Jonathan Wakely
2023-03-08 10:33               ` Jakub Jelinek

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=20230508080003.79d0e408@nbbrfq \
    --to=rep.dot.nop@gmail.com \
    --cc=aldot@gcc.gnu.org \
    --cc=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sgk@troutmask.apl.washington.edu \
    /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).