public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components
@ 2014-07-17 13:23 sfilippone at uniroma2 dot it
2014-07-17 13:24 ` [Bug fortran/61830] " sfilippone at uniroma2 dot it
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: sfilippone at uniroma2 dot it @ 2014-07-17 13:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
Bug ID: 61830
Summary: Memory leak with assignment to array of derived types
with allocatable components
Product: gcc
Version: 4.8.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: sfilippone at uniroma2 dot it
Created attachment 33132
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33132&action=edit
test case
Hi,
The attached code shows the problem.
When I started investigating I was using 4.10 but I ran into PR61819 while
reducing the test case.
With 4.8.3 I get the following:
--------------------------------------------
[sfilippo@jacobi runs]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu/4.8.3/libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.3/configure --prefix=/usr/local/gnu/4.8.3
--enable-languages=c,c++,fortran --with-gmp=/home/travel/GNUBUILD/gmp
--with-mpfr=/home/travel/GNUBUILD/mpfr --with-mpc=/home/travel/GNUBUILD/mpc
Thread model: posix
gcc version 4.8.3 (GCC)
[sfilippo@jacobi runs]$ valgrind --leak-check=full ./foo-test-leak
==20638== Memcheck, a memory error detector
==20638== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==20638== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==20638== Command: ./foo-test-leak
==20638==
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
==20638==
==20638== HEAP SUMMARY:
==20638== in use at exit: 6,164 bytes in 23 blocks
==20638== total heap usage: 89 allocs, 66 frees, 35,518 bytes allocated
==20638==
==20638== 560 (48 direct, 512 indirect) bytes in 1 blocks are definitely lost
in loss record 3 of 5
==20638== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==20638== by 0x400B70: __foo_base_mod_MOD_foo_geall (foo-test-leak.f90:96)
==20638== by 0x401F8B: __foo_scalar_field_mod_MOD_new_scalar_field
(foo-test-leak.f90:141)
==20638== by 0x40271F: __foo_vector_field_mod_MOD_new_vector_field
(foo-test-leak.f90:163)
==20638== by 0x402AC8: MAIN__ (foo-test-leak.f90:188)
==20638== by 0x4031D3: main (foo-test-leak.f90:179)
==20638==
==20638== 5,600 (480 direct, 5,120 indirect) bytes in 10 blocks are definitely
lost in loss record 5 of 5
==20638== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==20638== by 0x400B70: __foo_base_mod_MOD_foo_geall (foo-test-leak.f90:96)
==20638== by 0x401F8B: __foo_scalar_field_mod_MOD_new_scalar_field
(foo-test-leak.f90:141)
==20638== by 0x40271F: __foo_vector_field_mod_MOD_new_vector_field
(foo-test-leak.f90:163)
==20638== by 0x402C9E: MAIN__ (foo-test-leak.f90:192)
==20638== by 0x4031D3: main (foo-test-leak.f90:179)
==20638==
==20638== LEAK SUMMARY:
==20638== definitely lost: 528 bytes in 11 blocks
==20638== indirectly lost: 5,632 bytes in 11 blocks
==20638== possibly lost: 0 bytes in 0 blocks
==20638== still reachable: 4 bytes in 1 blocks
==20638== suppressed: 0 bytes in 0 blocks
==20638== Reachable blocks (those to which a pointer was found) are not shown.
==20638== To see them, rerun with: --leak-check=full --show-reachable=yes
==20638==
==20638== For counts of detected and suppressed errors, rerun with: -v
==20638== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6)
-------------------------------------------------------------------------------
If I change line 163
this%u = [new_scalar_field()]
into
do i=1, size(this%u)
associate(sf=>this%u(i))
sf = new_scalar_field()
end associate
end do
then I get no leak
[sfilippo@jacobi runs]$ valgrind --leak-check=full ./foo-test-leak-fixed
==20852== Memcheck, a memory error detector
==20852== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==20852== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==20852== Command: ./foo-test-leak-fixed
==20852==
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
Scalar deallocation
Deallocate class() component
==20852==
==20852== HEAP SUMMARY:
==20852== in use at exit: 4 bytes in 1 blocks
==20852== total heap usage: 67 allocs, 66 frees, 29,364 bytes allocated
==20852==
==20852== LEAK SUMMARY:
==20852== definitely lost: 0 bytes in 0 blocks
==20852== indirectly lost: 0 bytes in 0 blocks
==20852== possibly lost: 0 bytes in 0 blocks
==20852== still reachable: 4 bytes in 1 blocks
==20852== suppressed: 0 bytes in 0 blocks
==20852== Reachable blocks (those to which a pointer was found) are not shown.
==20852== To see them, rerun with: --leak-check=full --show-reachable=yes
==20852==
==20852== For counts of detected and suppressed errors, rerun with: -v
==20852== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
@ 2014-07-17 13:24 ` sfilippone at uniroma2 dot it
2014-07-17 13:42 ` dominiq at lps dot ens.fr
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sfilippone at uniroma2 dot it @ 2014-07-17 13:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
--- Comment #1 from Salvatore Filippone <sfilippone at uniroma2 dot it> ---
Created attachment 33133
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33133&action=edit
workaround
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
2014-07-17 13:24 ` [Bug fortran/61830] " sfilippone at uniroma2 dot it
@ 2014-07-17 13:42 ` dominiq at lps dot ens.fr
2014-12-25 23:15 ` dominiq at lps dot ens.fr
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-17 13:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-07-17
Ever confirmed|0 |1
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
2014-07-17 13:24 ` [Bug fortran/61830] " sfilippone at uniroma2 dot it
2014-07-17 13:42 ` dominiq at lps dot ens.fr
@ 2014-12-25 23:15 ` dominiq at lps dot ens.fr
2015-10-16 8:22 ` [Bug fortran/61830] [4.9/5/6 regression] " rguenth at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-25 23:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Note that the tests give an ICE with 4.9.2 and trunk (5.0):
end module foo_vector_field_mod
1
internal compiler error: in gfc_conv_descriptor_data_get, at
fortran/trans-array.c:146
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] [4.9/5/6 regression] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
` (2 preceding siblings ...)
2014-12-25 23:15 ` dominiq at lps dot ens.fr
@ 2015-10-16 8:22 ` rguenth at gcc dot gnu.org
2015-10-25 13:00 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-10-16 8:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.9.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] [4.9/5/6 regression] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
` (3 preceding siblings ...)
2015-10-16 8:22 ` [Bug fortran/61830] [4.9/5/6 regression] " rguenth at gcc dot gnu.org
@ 2015-10-25 13:00 ` dominiq at lps dot ens.fr
2015-10-25 21:31 ` pault at gcc dot gnu.org
2015-10-25 21:38 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-25 13:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The ICE is fixed by the patch submitted at
https://gcc.gnu.org/ml/fortran/2015-10/msg00117.html.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] [4.9/5/6 regression] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
` (4 preceding siblings ...)
2015-10-25 13:00 ` dominiq at lps dot ens.fr
@ 2015-10-25 21:31 ` pault at gcc dot gnu.org
2015-10-25 21:38 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2015-10-25 21:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Oct 25 21:31:12 2015
New Revision: 229303
URL: https://gcc.gnu.org/viewcvs?rev=229303&root=gcc&view=rev
Log:
2015-01-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/67171
* trans-array.c (structure_alloc_comps): On deallocation of
class components, reset the vptr to the declared type vtable
and reset the _len field of unlimited polymorphic components.
*trans-expr.c (gfc_find_and_cut_at_last_class_ref): Bail out on
allocatable component references to the right of part reference
with non-zero rank and return NULL.
(gfc_reset_vptr): Simplify this function by using the function
gfc_get_vptr_from_expr. Return if the vptr is NULL_TREE.
(gfc_reset_len): If gfc_find_and_cut_at_last_class_ref returns
NULL return.
* trans-stmt.c (gfc_trans_allocate): Rely on the use of
gfc_trans_assignment if expr3 is a variable expression since
this deals correctly with array sections.
2015-01-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/67171
* gfortran.dg/allocate_with_source_12.f03: New test
PR fortran/61819
* gfortran.dg/allocate_with_source_13.f03: New test
PR fortran/61830
* gfortran.dg/allocate_with_source_14.f03: New test
Added:
trunk/gcc/testsuite/gfortran.dg/allocate_with_source_12.f03
trunk/gcc/testsuite/gfortran.dg/allocate_with_source_13.f03
trunk/gcc/testsuite/gfortran.dg/allocate_with_source_14.f03
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/61830] [4.9/5/6 regression] Memory leak with assignment to array of derived types with allocatable components
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
` (5 preceding siblings ...)
2015-10-25 21:31 ` pault at gcc dot gnu.org
@ 2015-10-25 21:38 ` pault at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2015-10-25 21:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61830
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Fixed on trunk - I'll see what I can do for the earlier branches.
Thanks for the report
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-10-25 21:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17 13:23 [Bug fortran/61830] New: Memory leak with assignment to array of derived types with allocatable components sfilippone at uniroma2 dot it
2014-07-17 13:24 ` [Bug fortran/61830] " sfilippone at uniroma2 dot it
2014-07-17 13:42 ` dominiq at lps dot ens.fr
2014-12-25 23:15 ` dominiq at lps dot ens.fr
2015-10-16 8:22 ` [Bug fortran/61830] [4.9/5/6 regression] " rguenth at gcc dot gnu.org
2015-10-25 13:00 ` dominiq at lps dot ens.fr
2015-10-25 21:31 ` pault at gcc dot gnu.org
2015-10-25 21:38 ` pault at gcc dot gnu.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).