How to debug "Access not within mapped region" runtime error

Florian flad@gmx.at
Mon Aug 13 19:49:00 GMT 2007


I have a piece of code causing runtime troubles with gfortran (compiling 
problems are solved thanks to your quick patchings). It works with NAG, 
lahey, and intel fortran compiler, so I guess the troubles are related 
with gfortran, that's why I would ask for advice here how to debug the 
situation.

So far I didn't succeed to produce a compact test case, so I rather try 
to explain the behavior:

-------
gfortran --version
GNU Fortran (GCC) 4.3.0 20070808 (experimental)

flags:
gfortran -mtune=i586 -O0 -m32 -Wall -fbacktrace -g -fstack-check 
-fstack-protector-all -Wstack-protector -Wtabs .....
-------

Just running the code doesn't throw a runtime error, but after calling a 
subroutine (with many dummy arguments) the content of (at least) a 
variable   (CHARACTER (LEN = lenEventDateTime) :: StartDate)
gets lost. The content seems to get lost when calling another subroutine 
where this variable is a dummy argument. Most information is given by 
valgrind seemingly:

-----------------------
valgrind  ./MAnPl.x
==31165== Memcheck, a memory error detector.
==31165== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==31165== Using LibVEX rev 1732, a library for dynamic binary translation.
==31165== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==31165== Using valgrind-3.2.3-Debian, a dynamic binary instrumentation 
framework.
==31165== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==31165== For more details, rerun with: -v
==31165==
==31165== Invalid write of size 4
==31165==    at 0x80495E4: MAIN__ (MAnPl.f90:139)
==31165==    by 0x809CDC8: main (fmain.c:22)
==31165==  Address 0xBEC287E8 is not stack'd, malloc'd or (recently) free'd
==31165==
==31165== Invalid write of size 4
==31165==    at 0x8063747: __manpl_interface_MOD_get_manpl 
(manplinterface.f90:668)
==31165==    by 0x804973E: MAIN__ (MAnPl.f90:79)
==31165==    by 0x809CDC8: main (fmain.c:22)
==31165==  Address 0xBEC272F8 is not stack'd, malloc'd or (recently) free'd
==31165==
==31165== Process terminating with default action of signal 11 (SIGSEGV)
==31165==  Access not within mapped region at address 0xBEC272F8
==31165==    at 0x8063747: __manpl_interface_MOD_get_manpl 
(manplinterface.f90:668)
==31165==    by 0x804973E: MAIN__ (MAnPl.f90:79)
==31165==    by 0x809CDC8: main (fmain.c:22)
==31165==
==31165== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 17 from 1)
==31165== malloc/free: in use at exit: 25,533 bytes in 10 blocks.
==31165== malloc/free: 10 allocs, 0 frees, 25,533 bytes allocated.
==31165== For counts of detected errors, rerun with: -v
==31165== searching for pointers to 10 not-freed blocks.
==31165== checked 57,593,896 bytes.
==31165==
==31165== LEAK SUMMARY:
==31165==    definitely lost: 0 bytes in 0 blocks.
==31165==      possibly lost: 0 bytes in 0 blocks.
==31165==    still reachable: 25,533 bytes in 10 blocks.
==31165==         suppressed: 0 bytes in 0 blocks.
==31165== Rerun with --leak-check=full to see details of leaked memory.
Segmentation fault
-----------------------


Since I can't produce a short testcase reproducing the error I just send 
MAnPl.f90:79 appearing in the valgrind output above (79 is the last line 
of the following snippet) and the variable definitions:


-----------------------
    INTEGER Request_Type
    CHARACTER (LEN = lenEventDateTime) :: StartDate
    CHARACTER (LEN = lenDuration) :: TimeInterval
    DOUBLE PRECISION :: h(100), dh(100)
    DOUBLE PRECISION :: TimeStep
    CHARACTER*20 :: Tx_System, Rx_System
    INTEGER :: num_Tx_Systems
    INTEGER :: Tx_OrbitPropagator, Rx_OrbitPropagator, OrbitPropagator(2)
    INTEGER :: EarthFigure
    INTEGER                        :: Rx_N_Ant, Tx_N_Ant
    DOUBLE PRECISION, DIMENSION(2) :: Rx_bore_az, Rx_bore_elev, &
                                                  Rx_HPBW_hor, Rx_HPBW_ver
    DOUBLE PRECISION               :: Rx_zenithAntenna_elev_limit
    DOUBLE PRECISION, DIMENSION(2) :: Tx_bore_az, Tx_bore_elev, &
                                                  Tx_HPBW_hor, Tx_HPBW_ver
    INTEGER, DIMENSION(2)          :: Rx_FOV_Type, Tx_FOV_Type
    CHARACTER*128 :: Tx_TLE_files(MaxTXsystems)
    CHARACTER*128 :: Rx_TLE_file
    CHARACTER*128 :: TrackingSitesFile
    CHARACTER*128 :: FiducialSitesFile
    CHARACTER*128 :: Add_Rx_TLE_file
    TYPE (Geographical_Area) :: GeoArea
    CHARACTER*128 :: Out_File
    INTEGER :: Trackc,Diffc,AddLEOc
    INTEGER :: hlev

    character*50 :: project_id, task_id
    integer :: pid
    integer :: loopIndex

CALL Get_MAnPl(Request_Type, StartDate, TimeInterval,h ,dh, hlev, &
                TimeStep, Tx_System, num_Tx_Systems, &
                Tx_OrbitPropagator, Rx_System, Rx_OrbitPropagator, 
EarthFigure, &
                Rx_N_Ant, Rx_bore_az, Rx_bore_elev, &
                Rx_HPBW_hor, Rx_HPBW_ver, Rx_FOV_Type, &
                Rx_zenithAntenna_elev_limit, &
                Tx_N_Ant, Tx_bore_az, Tx_bore_elev, &
                Tx_HPBW_hor, Tx_HPBW_ver, Tx_FOV_Type, &
                Tx_TLE_files, Rx_TLE_file, Out_File, GeoArea, &
                Diffc,AddLEOc,Trackc,TrackingSitesFile,FiducialSitesFile, &
                Add_Rx_TLE_file, project_id, task_id, pid, loopIndex)
-----------------------


Maybe you can give me some advice how to provide more information, or 
even some idea what could go wrong here. Thanks,

florian






More information about the Fortran mailing list