Bug 45647 - compiler segfault when building coreutils-8.5 "head" program with -Os, -O2 or -O3
Summary: compiler segfault when building coreutils-8.5 "head" program with -Os, -O2 or...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-11 09:56 UTC by Michael Davies
Modified: 2010-09-11 13:41 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Coreutils 8.5 head.c preprocessed into head.i (26.99 KB, text/plain)
2010-09-11 12:23 UTC, Michael Davies
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Davies 2010-09-11 09:56:09 UTC
Be nice, this is my first attempt at filing a bug report ever :)

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --prefix=/home/suigintou/usr --enable-lto --with-mpfr=/home/suigintou/usr --with-gmp=/home/suigintou/usr --with-mpc=/home/suigintou/usr --with-ppl=/home/suigintou/usr --with-cloog=/home/suigintou/usr --with-libelf=/home/suigintou/usr --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++ --disable-libstdcxx-pch --disable-bootstrap --enable-clocale=gnu --disable-multilib
Thread model: posix
gcc version 4.6.0 20100824 (experimental) (GCC)



In coreutils-8.5/src, I type "make head", but this happens:

  CC       head.o
head.c: In function 'string_to_integer':
head.c:870:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [head.o] Error 1



Verbose...

make head V=2
/home/suigintou/bin/gcc -B /home/suigintou/lib -L/home/suigintou/lib  -I /home/suigintou/include -I /home/suigintou/usr/include -std=gnu99  -I. -I../lib  -I../lib    -pipe -U_FORTIFY_SOURCE -fno-stack-protector -Os -march=native -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mtune=core2 -fomit-frame-pointer -funroll-loops -floop-interchange -floop-strip-mine -floop-block -floop-parallelize-all -ftree-parallelize-loops=4 -MT head.o -MD -MP -MF .deps/head.Tpo -c -o head.o head.c
head.c: In function 'string_to_integer':


I was experimenting with graphite and other optimizations. Silly CFLAGS settings aside, I narrowed the cause down to that "-Os" flag. Gets the same problem if I use -O2 or -O3, but not if I use -O1 or -O0.
Comment 1 Michael Davies 2010-09-11 10:02:57 UTC
I'm unsure exactly how to get the preprocessed output required... 

I ran:

"/home/suigintou/bin/gcc -B /home/suigintou/lib -L/home/suigintou/lib  -I /home/suigintou/include -I /home/suigintou/usr/include -std=gnu99  -I. -I../lib  -I../lib    -pipe -U_FORTIFY_SOURCE -fno-stack-protector -Os -march=native -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mtune=core2 -fomit-frame-pointer -funroll-loops -floop-interchange -floop-strip-mine -floop-block -floop-parallelize-all -ftree-parallelize-loops=4 -MT head.o -MD -MP -MF .deps/head.Tpo -c -o head.o head.c -save-temps -v"

and got this output:

gcc: warning: -pipe ignored because -save-temps specified
Using built-in specs.
COLLECT_GCC=/home/suigintou/bin/gcc
COLLECT_LTO_WRAPPER=/usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu --prefix=/home/suigintou/usr --enable-lto --with-mpfr=/home/suigintou/usr --with-gmp=/home/suigintou/usr --with-mpc=/home/suigintou/usr --with-ppl=/home/suigintou/usr --with-cloog=/home/suigintou/usr --with-libelf=/home/suigintou/usr --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++ --disable-libstdcxx-pch --disable-bootstrap --enable-clocale=gnu --disable-multilib
Thread model: posix
gcc version 4.6.0 20100824 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-B' '/home/suigintou/lib' '-L/home/suigintou/lib' '-I' '/home/suigintou/include' '-I' '/home/suigintou/usr/include' '-std=gnu99' '-I.' '-I../lib' '-I../lib' '-pipe' '-U_FORTIFY_SOURCE' '-fno-stack-protector' '-Os'  '-msse' '-msse2' '-msse3' '-msse4' '-msse4.1' '-msse4.2' '-mssse3' '-mtune=core2' '-fomit-frame-pointer' '-funroll-loops' '-floop-interchange' '-floop-strip-mine' '-floop-block' '-floop-parallelize-all' '-ftree-parallelize-loops=4' '-MT' 'head.o' '-MD' '-MP' '-MF' '.deps/head.Tpo' '-c' '-o' 'head.o' '-save-temps' '-v' '-pthread'
 /usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.6.0/cc1 -E -quiet -v -I /home/suigintou/include -I /home/suigintou/usr/include -I. -I../lib -I../lib -iprefix /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.6.0/ -MD head.d -MF .deps/head.Tpo -MP -MT head.o -D_REENTRANT -U_FORTIFY_SOURCE head.c -march=core2 -mcx16 -msahf -mpopcnt -msse4.2 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mtune=core2 -std=gnu99 -fno-stack-protector -fomit-frame-pointer -funroll-loops -floop-interchange -floop-strip-mine -floop-block -floop-parallelize-all -ftree-parallelize-loops=4 -Os -fpch-preprocess -o head.i
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/4.6.0/include"
ignoring duplicate directory "/usr/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/4.6.0/include-fixed"
ignoring nonexistent directory "/usr/bin/../lib/gcc/../../lib/gcc/x86_64-pc-linux-gnu/4.6.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "/home/suigintou/include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "/home/suigintou/usr/include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory "../lib"
#include "..." search starts here:
#include <...> search starts here:
 .
 ../lib
 /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.6.0/include
 /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.6.0/include-fixed
 /usr/local/include
 /usr/bin/../lib/gcc/../../include
End of search list.
COLLECT_GCC_OPTIONS='-B' '/home/suigintou/lib' '-L/home/suigintou/lib' '-I' '/home/suigintou/include' '-I' '/home/suigintou/usr/include' '-std=gnu99' '-I.' '-I../lib' '-I../lib' '-pipe' '-U_FORTIFY_SOURCE' '-fno-stack-protector' '-Os'  '-msse' '-msse2' '-msse3' '-msse4' '-msse4.1' '-msse4.2' '-mssse3' '-mtune=core2' '-fomit-frame-pointer' '-funroll-loops' '-floop-interchange' '-floop-strip-mine' '-floop-block' '-floop-parallelize-all' '-ftree-parallelize-loops=4' '-MT' 'head.o' '-MD' '-MP' '-MF' '.deps/head.Tpo' '-c' '-o' 'head.o' '-save-temps' '-v' '-pthread'
 /usr/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.6.0/cc1 -fpreprocessed head.i -march=core2 -mcx16 -msahf -mpopcnt -msse4.2 -quiet -dumpbase head.c -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 -mssse3 -mtune=core2 -auxbase-strip head.o -Os -std=gnu99 -version -fno-stack-protector -fomit-frame-pointer -funroll-loops -floop-interchange -floop-strip-mine -floop-block -floop-parallelize-all -ftree-parallelize-loops=4 -o head.s
GNU C (GCC) version 4.6.0 20100824 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.5.1, GMP version 4.3.2, MPFR version 3.0.0-p4, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C (GCC) version 4.6.0 20100824 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.5.1, GMP version 4.3.2, MPFR version 3.0.0-p4, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 6fec6b818ac315d511f9303bd7ae32f3
head.c: In function 'string_to_integer':
head.c:870:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


and in head.i:
http://dpaste.org/RESS/
Comment 2 Richard Biener 2010-09-11 10:51:39 UTC
Please attach head.i here, pastes usually vanish after some time.
Comment 3 Michael Davies 2010-09-11 12:23:05 UTC
Created attachment 21775 [details]
Coreutils 8.5 head.c preprocessed into head.i

attached head.i for reference
Comment 4 H.J. Lu 2010-09-11 13:41:40 UTC
It has been fixed at least since revision 163804.