public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/66079] [6 Regression] memory leak with source allocation in internal subprogram
Date: Sat, 16 May 2015 08:24:00 -0000	[thread overview]
Message-ID: <bug-66079-4-CqK8LRYOxG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66079-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66079

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-05-16
                 CC|                            |pault at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Hi Damian,

The reason for this memory leak is rather obvious:

newrealvec ()
{
  struct subdata * d;

  try
    {
      d = 0B;
      {
        struct subdata D.3386;
        struct subdata D.3385;
        struct subdata subdata.0;

        subdata.0.b = (integer(kind=4) *) __builtin_malloc (4);
        *subdata.0.b = 0;
        D.3385 = subdata.0;
        D.3386 = D.3385;
        if (d != 0B)
          {
            _gfortran_runtime_error_at (&"At line 10 of file
pr66079.f90"[1]{lb: 1 sz: 1}, &"Attempting to allocate already allocated
variable \'%s\'"[1]{lb: 1 sz: 1}, &"d"[1]{lb: 1 sz: 1});
          }
        else
          {
            d = (struct subdata *) __builtin_malloc (8);
            if (d == 0B)
              {
                _gfortran_os_error (&"Allocation would exceed memory
limit"[1]{lb: 1 sz: 1});
              }
          }
        d->b = 0B;
        {
          struct subdata subdata.1;

          subdata.1.b = (integer(kind=4) *) __builtin_malloc (4);
          *subdata.1.b = 0;
          *d = subdata.1;
        }
      }
    }
  finally
    {
      if (d != 0B)
        {
          if (d->b != 0B)
            {
              __builtin_free ((void *) d->b);
            }
          d->b = 0B;
          __builtin_free ((void *) d);
        }
    }
}

subdata.1 gets freed in the finally block but subdata.0, which is redundant in
any case, does not.

Confirmed - thanks for the report.... I just have to find out why it is we wind
up with two subdata's.

Cheers

Paul


  parent reply	other threads:[~2015-05-16  8:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-66079-4@http.gcc.gnu.org/bugzilla/>
2015-05-11 10:51 ` rguenth at gcc dot gnu.org
2015-05-16  8:24 ` pault at gcc dot gnu.org [this message]
2015-05-16 15:32 ` pault at gcc dot gnu.org
2015-05-18  1:36 ` damian at sourceryinstitute dot org
2015-05-21  4:25 ` pault at gcc dot gnu.org
2015-05-22 22:57 ` pault at gcc dot gnu.org
2015-06-11 15:50 ` pault at gcc dot gnu.org
2015-06-13  0:21 ` damian at sourceryinstitute dot org
2015-08-04  9:27 ` mikael at gcc dot gnu.org
2015-08-04  9:32 ` paul.richard.thomas at gmail dot com
2015-10-16  8:34 ` [Bug fortran/66079] [5 " rguenth at gcc dot gnu.org
2015-10-16  8:34 ` rguenth at gcc dot gnu.org
2015-10-18 18:37 ` pault at gcc dot gnu.org
2015-10-18 19:43 ` pault at gcc dot gnu.org

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=bug-66079-4-CqK8LRYOxG@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).