PR38319 - Memory leaks in allocatable component expressions
Tobias Burnus
burnus@net-b.de
Sun Jan 31 15:18:00 GMT 2010
Dear Paul, hello all,
Paul Richard Thomas wrote:
> Having turned at last to this PR, I am now unable to find any runtime
> memory leaks using valgrind.
Using the test http://gcc.gnu.org/ml/fortran/2009-07/msg00260.html: "All
heap blocks were freed -- no leaks are possible", unless I use -pg which
shows a losted record in __gmon_start__.
(I have tried to check PR 40899 /
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/756be3846916a4b0
, but as the example is incomplete, I could not really test it; my small
test showed no problem. The comp.lang.fortran report and the fortran@
post above are both by Paul van Delst and look similar though not
identical.)
> The testcases that were supposed to leak
> were:
>
> alloc_comp_assign_2.f90 FOR_ALL problem(lines 27, 28 and 47)
> alloc_comp_assign_4.f90 nested constructors(line 56)
> alloc_comp_basics_2.f90 repeated ALLOCATE (lines 29, 30 and 35)
> alloc_comp_basics_5.f90 repeated ALLOCATE (lines 29, 30 and 35)
> alloc_comp_constructor_2.f90 nested constructors(line 23)
> alloc_comp_initializer_1.f90 nested constructors(line 43)
>
> All of the above show:
> ==12344== Conditional jump or move depends on uninitialised value(s)
>
I do not get those. However, I still get memory leaks:
$ gfortran -g alloc_comp_assign_2.f90
$ valgrind --leak-check=full --show-reachable=yes -- ./a.out
==17010== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
[...]
==17010== HEAP SUMMARY:
==17010== in use at exit: 384 bytes in 10 blocks
==17010== total heap usage: 38 allocs, 28 frees, 4,516 bytes allocated
==17010==
==17010== 32 bytes in 2 blocks are indirectly lost in loss record 1 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x401896: MAIN__ (alloc_comp_assign_2.f90:27)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
==17010==
==17010== 32 bytes in 2 blocks are indirectly lost in loss record 2 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x401E67: MAIN__ (alloc_comp_assign_2.f90:28)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
==17010==
==17010== 32 bytes in 2 blocks are indirectly lost in loss record 3 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x403B53: MAIN__ (alloc_comp_assign_2.f90:45)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
==17010==
==17010== 128 (96 direct, 32 indirect) bytes in 1 blocks are definitely
lost in loss record 4 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x40178E: MAIN__ (alloc_comp_assign_2.f90:27)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
==17010==
==17010== 128 (96 direct, 32 indirect) bytes in 1 blocks are definitely
lost in loss record 5 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x401D6B: MAIN__ (alloc_comp_assign_2.f90:28)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
==17010==
==17010== 128 (96 direct, 32 indirect) bytes in 2 blocks are definitely
lost in loss record 6 of 6
==17010== at 0x4C261C3: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17010== by 0x403A50: MAIN__ (alloc_comp_assign_2.f90:45)
==17010== by 0x405038: main (alloc_comp_assign_2.f90:51)
alloc_comp_assign_4.f90:
==17025== HEAP SUMMARY:
==17025== in use at exit: 8 bytes in 1 blocks
==17025== total heap usage: 31 allocs, 30 frees, 4,300 bytes allocated
==17025==
==17025== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==17025== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17025== by 0x400C6F: test_ab6.1531 (alloc_comp_assign_4.f90:56)
==17025== by 0x4033EE: MAIN__ (alloc_comp_assign_4.f90:36)
==17025== by 0x403612: main (alloc_comp_assign_4.f90:36)
alloc_comp_basics_2.f90
==17041== HEAP SUMMARY:
==17041== in use at exit: 116 bytes in 3 blocks
==17041== total heap usage: 24 allocs, 21 frees, 4,084 bytes allocated
==17041==
==17041== 20 bytes in 1 blocks are indirectly lost in loss record 1 of 3
==17041== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17041== by 0x401423: MAIN__ (alloc_comp_basics_2.f90:35)
==17041== by 0x4015A6: main (alloc_comp_basics_2.f90:39)
==17041==
==17041== 48 bytes in 1 blocks are definitely lost in loss record 2 of 3
==17041== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17041== by 0x400E73: MAIN__ (alloc_comp_basics_2.f90:7)
==17041== by 0x4015A6: main (alloc_comp_basics_2.f90:39)
==17041==
==17041== 68 (48 direct, 20 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3
==17041== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17041== by 0x400FF9: MAIN__ (alloc_comp_basics_2.f90:30)
==17041== by 0x4015A6: main (alloc_comp_basics_2.f90:39)
alloc_comp_basics_5.f90:
==17057== HEAP SUMMARY:
==17057== in use at exit: 40 bytes in 1 blocks
==17057== total heap usage: 17 allocs, 16 frees, 3,852 bytes allocated
==17057==
==17057== 40 bytes in 1 blocks are still reachable in loss record 1 of 1
==17057== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17057== by 0x400787: __bar_mod_MOD_bar_foo_ab (alloc_comp_basics_5.f90:25)
==17057== by 0x40080D: MAIN__ (alloc_comp_basics_5.f90:40)
==17057== by 0x400877: main (alloc_comp_basics_5.f90:36)
alloc_comp_constructor_2.f90:
==17093== HEAP SUMMARY:
==17093== in use at exit: 16 bytes in 2 blocks
==17093== total heap usage: 26 allocs, 24 frees, 4,068 bytes allocated
==17093==
==17093== 8 bytes in 1 blocks are definitely lost in loss record 1 of 2
==17093== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17093== by 0x40183A: MAIN__ (alloc_comp_constructor_2.f90:23)
==17093== by 0x40241A: main (alloc_comp_constructor_2.f90:26)
==17093==
==17093== 8 bytes in 1 blocks are definitely lost in loss record 2 of 2
==17093== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17093== by 0x401A4E: MAIN__ (alloc_comp_constructor_2.f90:23)
==17093== by 0x40241A: main (alloc_comp_constructor_2.f90:26)
alloc_comp_initializer_1.f90
==17121== 12 bytes in 1 blocks are definitely lost in loss record 1 of 1
==17121== at 0x4C261C3: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==17121== by 0x4011CC: MAIN__ (alloc_comp_initializer_1.f90:43)
==17121== by 0x4021E4: main (alloc_comp_initializer_1.f90:27)
Tobias
More information about the Fortran
mailing list