This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/66079] [6 Regression] memory leak with source allocation in internal subprogram
- From: "pault at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 16 May 2015 08:23:56 +0000
- Subject: [Bug fortran/66079] [6 Regression] memory leak with source allocation in internal subprogram
- Auto-submitted: auto-generated
- References: <bug-66079-4 at http dot gcc dot gnu dot 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