Hello,
after using valgrind to find errors on a big fortran 95/2003 code,
I've found a bug that I can reproduce on the small code below (two
files):
--------------------pointy.f90-------------------
module pointy
implicit none
integer, pointer :: ptr(:)
contains
subroutine to_point(var)
implicit none
integer, target :: var(:)
ptr => var
end subroutine to_point
end module pointy
-----------------------------------------------------
--------------------ptr_test.f90-----------------
program ptr_test
use pointy
implicit none
type my_type
integer :: dest
end type my_type
type(my_type), allocatable, target :: var_my_type(:)
allocate(var_my_type(2))
var_my_type%dest = 100
print*,'var_my_type%t ', var_my_type%dest
call to_point(var_my_type%dest)
print*,'ptr ', ptr
end program ptr_test
-----------------------------------------------------
I've compiled this code with gfortran 4.4.3.
Running this code on the VG, this is the result:
-----------------------
==25582== Memcheck, a memory error detector
==25582== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==25582== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==25582== Command: ./ptr_test
==25582==
var_my_type%t 100 100
==25582== Invalid read of size 4
==25582== at 0x4EF11B8: ??? (in /usr/lib/libgfortran.so.3.0.0)
==25582== by 0x4EF1321: ??? (in /usr/lib/libgfortran.so.3.0.0)
==25582== by 0x4EF40BE: ??? (in /usr/lib/libgfortran.so.3.0.0)
==25582== by 0x4EEA295: _gfortran_transfer_array (in
/usr/lib/libgfortran.so.3.0.0)
==25582== by 0x400D20: MAIN__ (ptr_test.f90:23)
==25582== by 0x400E19: main (in
/home/pedropl/OLAM/3.3-puffin/build_test/erro/ptr_test)
==25582== Address 0x5938f40 is 0 bytes inside a block of size 8 free'd
==25582== at 0x4C2748D: free (vg_replace_malloc.c:366)
==25582== by 0x400CB1: MAIN__ (ptr_test.f90:21)
==25582== by 0x400E19: main (in
/home/pedropl/OLAM/3.3-puffin/build_test/erro/ptr_test)
==25582==
ptr 100 100
==25582==
==25582== HEAP SUMMARY:
==25582== in use at exit: 0 bytes in 0 blocks
==25582== total heap usage: 18 allocs, 18 frees, 2,642 bytes allocated
==25582==
==25582== All heap blocks were freed -- no leaks are possible
==25582==
==25582== For counts of detected and suppressed errors, rerun with: -v
==25582== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 4 from 4)
---------------------
Am I doing something wrong?
Thanks a lot,
Pedro
------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk
Collect, index and harness all the fast moving IT data generated by your
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights.
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users