public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60913] New: Memory leak with deferred operators
@ 2014-04-21 10:12 alberto.ramos at desy dot de
  2014-04-21 12:38 ` [Bug fortran/60913] " tkoenig at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: alberto.ramos at desy dot de @ 2014-04-21 10:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60913

            Bug ID: 60913
           Summary: Memory leak with deferred operators
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alberto.ramos at desy dot de

Created attachment 32648
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32648&action=edit
Module with an overloaded operator with a deferred routine

When overloading an operator with a deferred procedure, gfortran leaks (i.e.
seem that does not free) memory.

I attach an example code that leaks around 60KB in my system with the following
compilers:


GNU Fortran (FreeBSD Ports Collection) 4.6.4
Copyright (C) 2011 Free Software Foundation, Inc.

GNU Fortran (FreeBSD Ports Collection) 4.8.3 20140220 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.


GNU Fortran (FreeBSD Ports Collection) 4.9.0 20140223 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.

Thanks,

A.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/60913] Memory leak with deferred operators
  2014-04-21 10:12 [Bug fortran/60913] New: Memory leak with deferred operators alberto.ramos at desy dot de
@ 2014-04-21 12:38 ` tkoenig at gcc dot gnu.org
  2014-04-21 12:47 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2014-04-21 12:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60913

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-21
                 CC|                            |tkoenig at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Valgrind shows:

ig25@linux-fd1f:~/Krempel/Leak> valgrind  --leak-check=full ./a.out
==4355== Memcheck, a memory error detector
==4355== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==4355== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==4355== Command: ./a.out
==4355== 
g:      2.3000E-01  4.6000E-01  6.9000E-01  9.2000E-01
g^-1:   3.2000E-01  6.4000E-01  9.6000E-01  1.2800E+00
gg^-1: -2.0608E+00  2.9440E-01  4.4160E-01  5.8880E-01
==4355== 
==4355== HEAP SUMMARY:
==4355==     in use at exit: 64,096 bytes in 2,003 blocks
==4355==   total heap usage: 2,028 allocs, 25 frees, 83,275 bytes allocated
==4355== 
==4355== 63,968 bytes in 1,999 blocks are definitely lost in loss record 5 of 5
==4355==    at 0x4C277AB: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==4355==    by 0x401109: __group_su2_MOD_prodsu2 (foo.f90:202)
==4355==    by 0x4017AE: MAIN__ (foo.f90:289)
==4355==    by 0x401A0C: main (foo.f90:268)
==4355== 
==4355== LEAK SUMMARY:
==4355==    definitely lost: 63,968 bytes in 1,999 blocks
==4355==    indirectly lost: 0 bytes in 0 blocks
==4355==      possibly lost: 0 bytes in 0 blocks
==4355==    still reachable: 128 bytes in 4 blocks
==4355==         suppressed: 0 bytes in 0 blocks
==4355== Reachable blocks (those to which a pointer was found) are not shown.
==4355== To see them, rerun with: --leak-check=full --show-reachable=yes
==4355== 
==4355== For counts of detected and suppressed errors, rerun with: -v
==4355== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)

where line 202 is

    Allocate(SU2::g3)

so the issue is with the allocatable function result of Prodsu2.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/60913] Memory leak with deferred operators
  2014-04-21 10:12 [Bug fortran/60913] New: Memory leak with deferred operators alberto.ramos at desy dot de
  2014-04-21 12:38 ` [Bug fortran/60913] " tkoenig at gcc dot gnu.org
@ 2014-04-21 12:47 ` dominiq at lps dot ens.fr
  2015-01-03 12:54 ` [Bug fortran/60913] [OOP] Memory leak with allocatable polymorphic function result (in type-bound operator) janus at gcc dot gnu.org
  2022-06-09 11:55 ` dr.i.j.bush at googlemail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-04-21 12:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60913

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |janus at gcc dot gnu.org

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from 4.6 to trunk (4.10). It may be a duplicate of pr55603.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/60913] [OOP] Memory leak with allocatable polymorphic function result (in type-bound operator)
  2014-04-21 10:12 [Bug fortran/60913] New: Memory leak with deferred operators alberto.ramos at desy dot de
  2014-04-21 12:38 ` [Bug fortran/60913] " tkoenig at gcc dot gnu.org
  2014-04-21 12:47 ` dominiq at lps dot ens.fr
@ 2015-01-03 12:54 ` janus at gcc dot gnu.org
  2022-06-09 11:55 ` dr.i.j.bush at googlemail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: janus at gcc dot gnu.org @ 2015-01-03 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|Memory leak with deferred   |[OOP] Memory leak with
                   |operators                   |allocatable polymorphic
                   |                            |function result (in
                   |                            |type-bound operator)

--- Comment #3 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #2)
> It may be a duplicate of pr55603.

Pretty much. But the case here is a bit more complicated, since the result is
polymorphic and the function is bound to a type-bound operator.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/60913] [OOP] Memory leak with allocatable polymorphic function result (in type-bound operator)
  2014-04-21 10:12 [Bug fortran/60913] New: Memory leak with deferred operators alberto.ramos at desy dot de
                   ` (2 preceding siblings ...)
  2015-01-03 12:54 ` [Bug fortran/60913] [OOP] Memory leak with allocatable polymorphic function result (in type-bound operator) janus at gcc dot gnu.org
@ 2022-06-09 11:55 ` dr.i.j.bush at googlemail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: dr.i.j.bush at googlemail dot com @ 2022-06-09 11:55 UTC (permalink / raw)
  To: gcc-bugs

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

dr.i.j.bush at googlemail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dr.i.j.bush at googlemail dot com

--- Comment #11 from dr.i.j.bush at googlemail dot com ---

Just wondering if any progress has been made/is likely on this bug - it
basically makes gfortran unusable with some of my latest code. I've tested Ian
Harvey's example with the latest version of the compiler I have and I see the
same problem as he reports:

ijb@ijb-Latitude-5410:~/work$ gfortran-11 -O -std=f2018 -Wall -Wextra
-fcheck=all ianh.f90 
ijb@ijb-Latitude-5410:~/work$ valgrind --leak-check=full ./a.out
==337876== Memcheck, a memory error detector
==337876== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==337876== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==337876== Command: ./a.out
==337876== 
           1
...
         100
==337876== 
==337876== HEAP SUMMARY:
==337876==     in use at exit: 400 bytes in 100 blocks
==337876==   total heap usage: 121 allocs, 21 frees, 13,984 bytes allocated
==337876== 
==337876== 400 bytes in 100 blocks are definitely lost in loss record 1 of 1
==337876==    at 0x483B7F3: malloc (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==337876==    by 0x401240: __m_MOD_f (in /home/ijb/work/a.out)
==337876==    by 0x4012C5: main (in /home/ijb/work/a.out)
==337876== 
==337876== LEAK SUMMARY:
==337876==    definitely lost: 400 bytes in 100 blocks
==337876==    indirectly lost: 0 bytes in 0 blocks
==337876==      possibly lost: 0 bytes in 0 blocks
==337876==    still reachable: 0 bytes in 0 blocks
==337876==         suppressed: 0 bytes in 0 blocks
==337876== 
==337876== For lists of detected and suppressed errors, rerun with: -s
==337876== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-09 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-21 10:12 [Bug fortran/60913] New: Memory leak with deferred operators alberto.ramos at desy dot de
2014-04-21 12:38 ` [Bug fortran/60913] " tkoenig at gcc dot gnu.org
2014-04-21 12:47 ` dominiq at lps dot ens.fr
2015-01-03 12:54 ` [Bug fortran/60913] [OOP] Memory leak with allocatable polymorphic function result (in type-bound operator) janus at gcc dot gnu.org
2022-06-09 11:55 ` dr.i.j.bush at googlemail dot com

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