Bug 716721 - gfortran :: compilation memory leak (leading to OOM killer)
Summary: gfortran :: compilation memory leak (leading to OOM killer)
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 15
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-26 16:23 UTC by Adrian Sevcenco
Modified: 2011-07-27 20:06 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-27 08:36:37 UTC
Type: ---


Attachments (Terms of Use)
valgrind --tool=memcheck --leak-check=full (14.17 KB, text/plain)
2011-06-26 21:49 UTC, Adrian Sevcenco
no flags Details
kernel log of OOM killer (11.02 KB, text/plain)
2011-06-26 21:50 UTC, Adrian Sevcenco
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 49540 0 None None None 2019-06-28 07:05:48 UTC

Description Adrian Sevcenco 2011-06-26 16:23:21 UTC
Description of problem:
compiling a piece of fortran code (that was compiling ok in Fedora 14) now leads to all memory eating (2 gb ram + 4gb swap) and action of OOM killer

Version-Release number of selected component (if applicable):
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.6.0 20110530 (Red Hat 4.6.0-9) (GCC)

How reproducible:
the piece of code is :
http://alisoft.cern.ch/viewvc/trunk/TAmpt/AMPT/hijing1.383_ampt.f?view=markup&root=AliRoot

the command is:
gfortran  -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_=\"TAmpt\" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN   -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f

CERNLIB is from official fedora repos (cernlib-2006-35.fc14.x86_64)
the rest of dependencies are from ROOT (http://root.cern.ch/drupal/) and
AliROOT (http://aliceinfo.cern.ch/Offline/AliRoot/Installation.html)



Steps to Reproduce:
1. the gfortran compilation of hijing1.383_ampt.f from http://alisoft.cern.ch/viewvc/trunk/TAmpt/AMPT/hijing1.383_ampt.f?view=markup&root=AliRoot

  
Actual results:
all memory (2 gb ram + 4 gb swap) steadly becomes occupied until OOM killer kills the gfortran :
gfortran: internal compiler error: Killed (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.


Expected results:
successful compilation (as in fedora 14)

Comment 1 Adrian Sevcenco 2011-06-26 17:18:00 UTC
a little strange thing is strace totals:

adrian@sevdell: TAmpt $ strace -c  gfortran  -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_=\"TAmpt\" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN   -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f
gfortran: internal compiler error: Killed (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 99.99    8.723674     8723674         1           wait4
  0.01    0.001000        1000         1           unlink
  0.00    0.000027           2        17         7 access
  0.00    0.000000           0         1           read
  0.00    0.000000           0         3           write
  0.00    0.000000           0         5         3 open
  0.00    0.000000           0         2           close
  0.00    0.000000           0         6         2 stat
  0.00    0.000000           0         1           fstat
  0.00    0.000000           0         6           lstat
  0.00    0.000000           0         6           mmap
  0.00    0.000000           0         3           mprotect
  0.00    0.000000           0         5           brk
  0.00    0.000000           0         9           rt_sigaction
  0.00    0.000000           0         1           getpid
  0.00    0.000000           0         1           vfork
  0.00    0.000000           0         1           execve
  0.00    0.000000           0         1           arch_prctl
------ ----------- ----------- --------- --------- ----------------
100.00    8.724701                    70        12 total


trying to use valgrind give little info:

adrian@sevdell: TAmpt $ valgrind --tool=memcheck gfortran  -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_=\"TAmpt\" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN   -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f
==30819== Memcheck, a memory error detector
==30819== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==30819== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==30819== Command: gfortran -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_="TAmpt" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f
==30819== 
gfortran: internal compiler error: Killed (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
==30819== 
==30819== HEAP SUMMARY:
==30819==     in use at exit: 35,679 bytes in 122 blocks
==30819==   total heap usage: 190 allocs, 68 frees, 46,047 bytes allocated
==30819== 
==30819== LEAK SUMMARY:
==30819==    definitely lost: 5,124 bytes in 28 blocks
==30819==    indirectly lost: 45 bytes in 3 blocks
==30819==      possibly lost: 29 bytes in 2 blocks
==30819==    still reachable: 30,481 bytes in 89 blocks
==30819==         suppressed: 0 bytes in 0 blocks
==30819== Rerun with --leak-check=full to see details of leaked memory
==30819== 
==30819== For counts of detected and suppressed errors, rerun with: -v
==30819== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)

and with --leak-check=full give absolutely no info:

adrian@sevdell: TAmpt $ valgrind --tool=memcheck --leak-check=full gfortran  -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_=\"TAmpt\" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN   -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f
==31834== Memcheck, a memory error detector
==31834== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==31834== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==31834== Command: gfortran -o CMakeFiles/ampt.dir/AMPT/hijing1.383_ampt.f.o -Dampt_EXPORTS -Dlinux -D_MODULE_="TAmpt" -DFORTRAN_GFORTRAN -DCERNLIB_LINUX -DCERNLIB_BLDLIB -DCERNLIB_CZ -O -g -fPIC -fno-second-underscore -fPIC -fno-f2c -fPIC -I/home/physics-tools/root/root/include -I/home/physics-tools/alice/aliroot/STEER -I/home/physics-tools/alice/aliroot/TAmpt -I/home/physics-tools/alice/aliroot/objdir/include -I/home/physics-tools/alice/aliroot/TAmpt/AMPT -I/home/physics-tools/alice/aliroot/EVGEN -c /home/physics-tools/alice/aliroot/TAmpt/AMPT/hijing1.383_ampt.f
==31834== 
Killed

i know the fedora 15 come with cgroups enabled .. is it possible that valgrind is in the same group with gfortran and so OOM killer kills the whole group?
How can i debug further this problem?
Many thanks!
Adrian

Comment 2 Adrian Sevcenco 2011-06-26 21:49:51 UTC
Created attachment 509998 [details]
valgrind --tool=memcheck --leak-check=full

Comment 3 Adrian Sevcenco 2011-06-26 21:50:39 UTC
Created attachment 509999 [details]
kernel log of OOM killer

Comment 4 Jakub Jelinek 2011-06-27 08:36:37 UTC
It is not a memory leak, just the FE expanding the whole initializer (which is admittedly huge).  Tracking upstream.

Comment 5 Adrian Sevcenco 2011-07-27 19:58:25 UTC
It seems that upstream was fixed.. was the patch backported to f15?
Thanks

Comment 6 Jakub Jelinek 2011-07-27 20:06:21 UTC
It is in gcc-gfortran-4.6.1-3.fc15 and above.  Though those exist right now just in koji, pushing it as errata will happen later on when more bugs accumulate.


Note You need to log in before you can comment on or make changes to this bug.