public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38319] Memory leaks in allocatable component expressions
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
@ 2012-02-22 13:34 ` xiaoyuanbo at yeah dot net
2015-01-03 10:19 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: xiaoyuanbo at yeah dot net @ 2012-02-22 13:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
xiaoyuanbo <xiaoyuanbo at yeah dot net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xiaoyuanbo at yeah dot net
--- Comment #6 from xiaoyuanbo <xiaoyuanbo at yeah dot net> 2012-02-22 12:54:34 UTC ---
you know that title
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 13:34 ` [Bug fortran/38319] Memory leaks in allocatable component expressions xiaoyuanbo at yeah dot net
@ 2015-01-03 10:19 ` janus at gcc dot gnu.org
2015-01-03 13:33 ` janus at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2015-01-03 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |janus at gcc dot gnu.org
--- Comment #7 from janus at gcc dot gnu.org ---
I think it is indeed expected for valgrind to report leaks for the code in
comment 5, since variables in the main program are not supposed to be
auto-deallocated in F08.
Valgrind does not show any leaks if I put x into a subroutine:
type :: thytype
integer(4), allocatable :: h(:)
end type thytype
type :: mytype
type(thytype), allocatable :: q(:)
end type mytype
contains
subroutine s
type (mytype) :: x
x = mytype ([thytype([555])])
end subroutine
end
One should check the test cases listed in comment 0, in order to see if they
still show leaks and if those are actual bugs.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 13:34 ` [Bug fortran/38319] Memory leaks in allocatable component expressions xiaoyuanbo at yeah dot net
2015-01-03 10:19 ` janus at gcc dot gnu.org
@ 2015-01-03 13:33 ` janus at gcc dot gnu.org
2021-02-01 8:29 ` burnus at gcc dot gnu.org
2021-02-01 12:54 ` pault at gcc dot gnu.org
4 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu.org @ 2015-01-03 13:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
--- Comment #8 from janus at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #0)
> alloc_comp_assign_4.f90 nested constructors(line 56)
With current trunk I see additional leaks in lines 28 and 29. Those are again
due to not auto-deallocating variables in the main program, which is an F08
feature, not a gfortran bug.
The leak in line 56 persists. Here is a reduced test case for that:
type :: a
character(4), allocatable :: ch(:)
end type a
call test_ab6 ()
contains
subroutine test_ab6 ()
type b
type(a) :: a
end type b
type c
type(b), allocatable :: b(:)
end type c
type(c) :: p
p = c((/b(a((/"Mary","Lamb"/)))/))
end subroutine
end
While 4.4 shows only a single 8-byte leak, 4.6 to trunk shows two of them.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2015-01-03 13:33 ` janus at gcc dot gnu.org
@ 2021-02-01 8:29 ` burnus at gcc dot gnu.org
2021-02-01 12:54 ` pault at gcc dot gnu.org
4 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-02-01 8:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #11 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Related / same issue:
https://gcc.gnu.org/pipermail/fortran/2021-January/055654.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2021-02-01 8:29 ` burnus at gcc dot gnu.org
@ 2021-02-01 12:54 ` pault at gcc dot gnu.org
4 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu.org @ 2021-02-01 12:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
--- Comment #12 from Paul Thomas <pault at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #11)
> Related / same issue:
> https://gcc.gnu.org/pipermail/fortran/2021-January/055654.html
Hi Tobias,
Over the weekend, I had a stab at fixing this recent issue. I can fix this but
at the risk of increasing the problem of leaks in the original examples in this
PR and causing some regressions.
I am going to make the testcase for PR98342 leak free so that the the specific
problems are separated.
Cheers
Paul
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
` (4 preceding siblings ...)
2010-02-25 12:51 ` paul dot richard dot thomas at gmail dot com
@ 2010-02-25 13:54 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-25 13:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2010-02-25 13:54 -------
type :: thytype
integer(4), allocatable :: h(:)
end type thytype
type :: mytype
type(thytype), allocatable :: q(:)
end type mytype
type (mytype) :: x
x = mytype ([thytype([555])])
end
Reduced test case. If I read the dump correctly, one effectively does:
tmp = thytype([555])
x = mytype(tmp)
however, for "mytype(tmp)" the data is copied instead of simply assigning the
pointer "tmp.data" and "tmp.data" is never freed.
a) One creates "thytype" with the value 555:
(*(struct thytype[1] * restrict) atmp.1.data)[0] = thytype.4;
- and recopying again:
(*(struct thytype[1] * restrict) atmp.7.data)[S.9] = (*(struct thytype[1] *
restrict) atmp.1.data)[S.9];
b) One now assigns that data to "mytype" - but not directly but via
malloc+memcopy:
D.1592 = (void * restrict) __builtin_malloc (MAX_EXPR <D.1591, 1>);
(*(struct thytype[0:] * restrict) mytype.0.q.data)[S.10].h.data = D.1592;
__builtin_memcpy ((integer(kind=4)[0:] * restrict) (*(struct thytype[0:] *
restrict) mytype.0.q.data)[S.10].h.data, (integer(kind=4)[0:] * restrict)
(*(struct thytype[1] * restrict) atmp.7.data)[S.10].h.data, D.1590 * 4);
The problem is now that "atmp.7.data.h.data" is never freed.
It would be fantastic if instead of freeing atmp.7.data.h.data one could simply
assign atmp.7.data.h.data to mytype.0.q.data[S.10].h.data without
malloc/memcpy. I am sure it is nontrivial, but I would really like to see the
number of temporaries be cut down. The dumps are pretty hard to read and we
probably give also the middle end a hard time in figuring out that we do not
need ~8 mallocs but one three - especially since the middle end does not really
optimize malloc/free (it could, but it doesn't - yet).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
` (3 preceding siblings ...)
2010-02-25 7:38 ` burnus at gcc dot gnu dot org
@ 2010-02-25 12:51 ` paul dot richard dot thomas at gmail dot com
2010-02-25 13:54 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: paul dot richard dot thomas at gmail dot com @ 2010-02-25 12:51 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]
------- Comment #4 from paul dot richard dot thomas at gmail dot com 2010-02-25 12:50 -------
Subject: Re: Memory leaks in allocatable component
expressions
> ------- Comment #3 from burnus at gcc dot gnu dot org 2010-02-25 07:38 -------
> Paul, can you try with valgrind --leak-check=full ? Without the =full option,
> I also do not get any line info output but just in the summary "definitely
> lost: 288 bytes in 4 blocks".
Tobias,
I cannot remember how valgrind puts it but I get the no memory leaks
possible message, even with =full.
Cheers
Possible
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
` (2 preceding siblings ...)
2010-02-24 20:31 ` pault at gcc dot gnu dot org
@ 2010-02-25 7:38 ` burnus at gcc dot gnu dot org
2010-02-25 12:51 ` paul dot richard dot thomas at gmail dot com
2010-02-25 13:54 ` burnus at gcc dot gnu dot org
5 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-25 7:38 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-02-25 07:38 -------
Paul, can you try with valgrind --leak-check=full ? Without the =full option,
I also do not get any line info output but just in the summary "definitely
lost: 288 bytes in 4 blocks".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
2008-11-29 21:55 ` [Bug fortran/38319] " pault at gcc dot gnu dot org
2009-07-30 19:07 ` burnus at gcc dot gnu dot org
@ 2010-02-24 20:31 ` pault at gcc dot gnu dot org
2010-02-25 7:38 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-02-24 20:31 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
------- Comment #2 from pault at gcc dot gnu dot org 2010-02-24 20:31 -------
I have been having trouble in recent times detecting these memory leaks.
Neither FC9 nor RHEL5.2 x86_64 seem to show them with valgrind. Since I know
that others still see them, I wonder are there any ideas what I have to do to
detect them? It´s a tad difficult to fix the memory leaks if I cannot detect
them :-)
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
2008-11-29 21:55 ` [Bug fortran/38319] " pault at gcc dot gnu dot org
@ 2009-07-30 19:07 ` burnus at gcc dot gnu dot org
2010-02-24 20:31 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-07-30 19:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2009-07-30 19:07 -------
See also http://gcc.gnu.org/ml/fortran/2009-07/msg00260.html and PR 40899.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/38319] Memory leaks in allocatable component expressions
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
@ 2008-11-29 21:55 ` pault at gcc dot gnu dot org
2009-07-30 19:07 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-29 21:55 UTC (permalink / raw)
To: gcc-bugs
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2008-11-29 21:54:13
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38319
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-02-01 12:54 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-38319-4@http.gcc.gnu.org/bugzilla/>
2012-02-22 13:34 ` [Bug fortran/38319] Memory leaks in allocatable component expressions xiaoyuanbo at yeah dot net
2015-01-03 10:19 ` janus at gcc dot gnu.org
2015-01-03 13:33 ` janus at gcc dot gnu.org
2021-02-01 8:29 ` burnus at gcc dot gnu.org
2021-02-01 12:54 ` pault at gcc dot gnu.org
2008-11-29 21:55 [Bug fortran/38319] New: " pault at gcc dot gnu dot org
2008-11-29 21:55 ` [Bug fortran/38319] " pault at gcc dot gnu dot org
2009-07-30 19:07 ` burnus at gcc dot gnu dot org
2010-02-24 20:31 ` pault at gcc dot gnu dot org
2010-02-25 7:38 ` burnus at gcc dot gnu dot org
2010-02-25 12:51 ` paul dot richard dot thomas at gmail dot com
2010-02-25 13:54 ` burnus at gcc dot gnu dot org
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).