Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

glibc detected : double free or corruption - ifort Intel v.14.0.2.144

Brandon_F_
Beginner
1,858 Views

Hello,

I am having an executable crash, receiving a glibc (double free or corruption (out)) error:

*** glibc detected *** a.out: double free or corruption (out): 0x00002ab517bd0010 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x76808)[0x2ab5140ee808]
/lib64/libc.so.6(cfree+0x6c)[0x2ab5140f384c]
a.out[0x45ea29]
a.out[0x439559]
a.out[0x441e88]
a.out[0x403536]
/lib64/libc.so.6(__libc_start_main+0xe6)[0x2ab514096c16]
a.out[0x403429]
======= Memory map: ========

The program is compiled with no errors:

ifort -c -CB -CU -ftrapuv -par_report0 -vec_report0 -heap-arrays -stand f03 -check all -traceback -warn all -fstack-protector -assume protect_parens -implicitnone -g -I/opt/cray/netcdf/4.3.0/cray/81/include/ CAM_netcdf_to_WRF_intermediate.f90 ; ifort CAM_netcdf_to_WRF_intermediate.o -L/opt/cray/netcdf/4.3.0/cray/81/lib/ -lnetcdff

Assuming it is some memory corruption, I used valgrind to try and locate the problem:

valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes a.out

Like any fortran program valgrind returns many conditional jumps. There are also several instances of 'uninitialised value of size 8', and some 'Invalid read of size 8' and 'Invalid write of size 1'. Before the heap summary, there is a segmentation fault 'Invalid free() / delete / delete[] / realloc(). Despite the overwhelming amount of output from valgrind, I am still unable to track down the source of the problem. Please see attached output from valgrind (valgrind.stdout).

The fortran script does not contain any pointers, and crashes sometime between the termination of the subroutine (read_netcdf_CAM_andCLM_files) and the reading of the next filename (after the call statement near print statement '13a'). Please see the attached fortran script (CAM_netcdf_to_WRF_intermediate.f90.

I would appreciate any feedback. Thanks in advance.

0 Kudos
2 Replies
TimP
Honored Contributor III
1,858 Views

A possible explanation for the error might be that the program closes a file which is already closed or hasn't been opened (or that the file system state has been clobbered).   It might be helpful to put more error checking in the file I/O (open, close, read, write) so as to catch the error where it occurs.

0 Kudos
Brandon_F_
Beginner
1,858 Views

Regarding the file I/O, there does not appear to be any issues opening, closing and reading the files. Writing the output happens in another subroutine that is called later in MAIN - the program crashes before calling this subroutine.

How would I go about diagnosing whether the system state has been clobbered?

0 Kudos
Reply