Memory leaks in standard code
FX Coudert
fxcoudert@gmail.com
Tue Feb 26 23:49:00 GMT 2008
> It's weird, because I don't see that. Adding a simple printf() to
> both malloc_check and free_check, I get:
>
> Malloc'ed memory at 0x5ae260
> Malloc'ed memory at 0x5ae2b0
> Freeing memory at 0x5ae2b0
>
> (followed by erroneous messages; I removed the "sys_exit(2)" to
> prevent the program from stopping). I will investigate the hashtab
> issues on my side (it seems to be simple, but 3 levels of
> indirections is one too many for my simple mind), but it seems that
> on your testcase (reproduced below), the memory of the first malloc
> (reportedly at line 6 of a.f90) is never free'd.
OK, I've managed to fix my hashtab code, and I've reworked the error
messages a bit, so your testcase now gives:
$ ./bin/gfortran a.f90 -static -fruntime-check=memleaks && ./a.out
Fortran runtime checking: found 1 memory leaks
!! Memory leak in the code generated by the GNU Fortran compiler.
!! Please report this issue to http://gcc.gnu.org/bugzilla/
Peak user-allocated memory: 0.00 B
Peak memory created by the compiler for temporaries: 24.0 B
I attach the new patch here; only the libgfortran/ diff is included,
the front-end part is untouched; Makefile.in diff is included :)
It fixes the hashtab issue, adds better error messages and should
support calls to realloc(). I'm still unsure when exactly these calls
are triggered, so if you can provide me with one of more testcases
(or name of testcases from the testsuite), I'd be glad to try it. For
now, that part is still untested.
FX
--
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
More information about the Fortran
mailing list