Huge memory usage with current g++ :-( -> endless (?) recursion in walk_tree <expand_call_inline>

Andreas Jaeger aj@suse.de
Wed Jul 26 09:32:00 GMT 2000


Trying to bootstrap gcc from CVS with:
/cvs/gcc/configure --prefix=/opt/gcc-2.96.test --enable-shared --enable-threads \
         --with-gnu-as --with-gnu-ld
on i686-linux (kernel 2.2.16, glibc 2.1.3) I noticed that compiling
libstdc++ lead to an enourmous memory usage (my machine has 256 MB of
main memory and g++ used more than 400 MB).  The problem occurs with
the following command:

echo cstring
cstring
if [ x"-fpic" != x ]; then \
  /builds/gcc/gcc-2.96/gcc/g++ -B/opt/gcc-2.96.test/i686-pc-linux/bin/ -B/opt/gcc-2.9
6.test/i686-pc-linux/lib/ -B/builds/gcc/gcc-2.96/gcc/ -isystem /opt/gcc-2.96.test/i68
6-pc-linux/include -L/builds/gcc/gcc-2.96/i686-pc-linux/libstdc++ -c -g -O2 -fvtable-
thunks -D_GNU_SOURCE -fno-implicit-templates -I/cvs/gcc/libstdc++ -I/cvs/gcc/libstdc+
+/stl -I../libio -I/cvs/gcc/libstdc++/../libio -nostdinc++ -D_IO_MTSAFE_IO -fpic -DC 
\
    `for N in REP MAIN TRAITS ADDSS ADDPS ADDCS ADDSP ADDSC EQSS EQPS EQSP NESS NEPS 
NESP LTSS LTPS LTSP GTSS GTPS GTSP LESS LEPS LESP GESS GEPS GESP; do echo " -D${N}"; 
done` \
    /cvs/gcc/libstdc++/sinst.cc -o pic/cstrmain.o; \
else true ; fi

Using -O1 instead of -O2 fixed this.

After setting ulimit to 128 MB I got:
if [ x"-fpic" != x ]; then \
  /builds/gcc/gcc-2.96/gcc/g++ -B/opt/gcc-2.96.test/i686-pc-linux/bin/ -B/opt/gcc-2.96.test/i686-pc-linux/lib/ -B/builds/gcc/gcc-2.96/gcc/ -isystem /opt/gcc-2.96.test/i686-pc-linux/include -L/builds/gcc/gcc-2.96/i686-pc-linux/libstdc++ -c -g -O2 -fvtable-thunks -D_GNU_SOURCE -fno-implicit-templates -I/cvs/gcc/libstdc++ -I/cvs/gcc/libstdc++/stl -I../libio -I/cvs/gcc/libstdc++/../libio -nostdinc++ -D_IO_MTSAFE_IO -fpic -DC \
    `for N in REP MAIN TRAITS ADDSS ADDPS ADDCS ADDSP ADDSC EQSS EQPS EQSP NESS NEPS NESP LTSS LTPS LTSP GTSS GTPS GTSP LESS LEPS LESP GESS GEPS GESP; do echo " -D${N}"; done` \
    /cvs/gcc/libstdc++/sinst.cc -o pic/cstrmain.o; \
else true ; fi
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.

Ok, here we go:

$ /builds/gcc/gcc-2.96/gcc/g++ -B/opt/gcc-2.96.test/i686-pc-linux/bin/ -B/opt/gcc-2.96.test/i686-pc-linux/lib/ -B/builds/gcc/gcc-2.96/gcc/ -isystem /opt/gcc-2.96.test/i686-pc-linux/include -L/builds/gcc/gcc-2.96/i686-pc-linux/libstdc++ -c -g -O2 -fvtable-thunks -D_GNU_SOURCE -fno-implicit-templates -I/cvs/gcc/libstdc++ -I/cvs/gcc/libstdc++/stl -I../libio -I/cvs/gcc/libstdc++/../libio -nostdinc++ -D_IO_MTSAFE_IO -fpic -DC /cvs/gcc/libstdc++/sinst.cc -o pic/cstrmain.o -DREP -DMAIN -DTRAITS -DADDSS -DADDPS -DADDCS -DADDSP -DADDSC -DEQSS -DEQPS -DEQSP -DNESS -DNEPS -DNESP -DLTSS -DLTPS -DLTSP -DGTSS -DGTPS -DGTSP -DLESS -DLEPS -DLESP -DGESS -DGEPS -DGESP -v -save-temps
Reading specs from /builds/gcc/gcc-2.96/gcc/specs
gcc version 2.96 20000726 (experimental)
 /builds/gcc/gcc-2.96/gcc/cpp -lang-c++ -D__GNUG__=2 -nostdinc++ -v -I/cvs/gcc/libstdc++ -I/cvs/gcc/libstdc++/stl -I../libio -I/cvs/gcc/libstdc++/../libio -iprefix /builds/gcc/gcc-2.96/gcc/../lib/gcc-lib/i686-pc-linux/2.96/ -isystem /builds/gcc/gcc-2.96/gcc/include -isystem /opt/gcc-2.96.test/i686-pc-linux/lib/include -isystem /opt/gcc-2.96.test/i686-pc-linux/bin/include -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__OPTIMIZE__ -g -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_pentiumpro__ -D__PIC__ -D__pic__ -D_GNU_SOURCE -D_IO_MTSAFE_IO -DC -DREP -DMAIN -DTRAITS -DADDSS -DADDPS -DADDCS -DADDSP -DADDSC -DEQSS -DEQPS -DEQSP -DNESS -DNEPS -DNESP -DLTSS -DLTPS -DLTSP -DGTSS -DGTPS -DGTSP -DLESS -DLEPS -DLESP -DGESS -DGEPS -DGESP -isystem /opt/gcc-2.96.test/i686-pc-linux/include /cvs/gcc/libstdc++/sinst.cc sinst.ii
GNU CPP version 2.96 20000726 (experimental) (cpplib)
 (i386 Linux/ELF)
ignoring nonexistent directory "/opt/gcc-2.96.test/i686-pc-linux/lib/include"
ignoring nonexistent directory "/opt/gcc-2.96.test/i686-pc-linux/bin/include"
ignoring nonexistent directory "/builds/gcc/gcc-2.96/lib/gcc-lib/i686-pc-linux/2.96/include"
ignoring nonexistent directory "/builds/gcc/gcc-2.96/i686-pc-linux/include"
ignoring duplicate directory "/opt/gcc-2.96.test/i686-pc-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /cvs/gcc/libstdc++
 /cvs/gcc/libstdc++/stl
 ../libio
 /cvs/gcc/libio
 /builds/gcc/gcc-2.96/gcc/include
 /opt/gcc-2.96.test/i686-pc-linux/include
 /usr/local/include
 /opt/gcc-2.96.test/lib/gcc-lib/i686-pc-linux/2.96/include
 /usr/include
End of search list.
 /builds/gcc/gcc-2.96/gcc/cc1plus sinst.ii -quiet -dumpbase sinst.cc -g -O2 -version -fvtable-thunks -fno-implicit-templates -fpic -o sinst.s
GNU C++ version 2.96 20000726 (experimental) (i686-pc-linux) compiled by GNU C version 2.96 20000726 (experimental).
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.


backtrace in gdb shows over 160000 calls of walk_tree - all with <expand_call_inline>:
$ bt
#0  0x831fda1 in expand_call_inline (tp=0x4028c790, walk_subtrees=0xb8e8402c, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/optimize.c:618
#1  0x8314991 in walk_tree (tp=0x4028c790, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1248
#2  0x8314b6a in walk_tree (tp=0x4028c770, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1283
#3  0x8314b6a in walk_tree (tp=0x4028c750, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1283
#4  0x8314b6a in walk_tree (tp=0x4028c730, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1283
#5  0x8314b6a in walk_tree (tp=0x4028c5e0, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1283
#6  0x8314eba in walk_tree (tp=0x4028c4c0, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1303
#7  0x8314eba in walk_tree (tp=0x4028c320, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1303
#8  0x8314eba in walk_tree (tp=0x4028c180, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1303
[...]
#166770 0x8314b6a in walk_tree (tp=0x4064313c, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1283
#166771 0x8314d19 in walk_tree (tp=0x4028c780, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1298
#166772 0x8314eba in walk_tree (tp=0x4028c770, func=0x831fd90 <expand_call_inline>, data=0xbfffe9f4) at /cvs/gcc/gcc/cp/tree.c:1303
[stopped]

I'm appending the sinst.ii file.  If anybody has any suggestion how I
could debug it, please tell me.  I've noticed this first at the
beginning of this week but did my last successfull bootstrap before
that around the 15th.

Andreas 



More information about the Gcc-bugs mailing list