Bug 39641

Summary: Compiling Linux 2.6.28.6 ends with a segfault on net/core/skbuff.c
Product: gcc Reporter: Lasse Kliemann <lasse-gccbug-2009>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: gcc-bugs
Priority: P3 Keywords: ice-on-valid-code
Version: 4.1.2   
Target Milestone: ---   
Host: Target: i686-pc-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: Preprocessed source file
Kernel configuration which triggers the problem

Description Lasse Kliemann 2009-04-04 22:22:52 UTC
Compiling Linux 2.6.28.6 ends with a segfault.

I will attach preprocessed source files and kernel configuration file when I find out how to do this with this interface. Here is some information for now:

Configure switches for gcc (besides prefix):
--enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-checking --disable-werror --enable-bootstrap --enable-languages=c,c++

Thread model: posix

Command line:
gcc -Wp,-MD,net/core/.skbuff.o.d  -nostdinc -isystem /package/host/localhost/sepbuilt/gcc41-4.1.2-01-03/prefix/lib/gcc/i686-pc-linux-gnu/4.1.2/include -D__KERNEL__ -Iinclude  -I/fs/tmp/mount/tmp/linux-2.6.28.6/arch/x86/include -include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -O2 -m32 -msoft-float -mregparm=3 -freg-struct-return -mpreferred-stack-boundary=2 -march=i586 -mtune=i686 -Wa,-mtune=generic32 -ffreestanding -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Iarch/x86/include/asm/mach-default -fno-stack-protector -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(skbuff)"  -D"KBUILD_MODNAME=KBUILD_STR(skbuff)"  -c -o net/core/skbuff.o net/core/skbuff.c

Output:
net/core/skbuff.c:2673: internal compiler error: Segmentation fault
Comment 1 Lasse Kliemann 2009-04-04 22:27:15 UTC
Created attachment 17588 [details]
Preprocessed source file

The file is over 1 MB when uncompressed.
Comment 2 Lasse Kliemann 2009-04-04 22:29:22 UTC
Created attachment 17589 [details]
Kernel configuration which triggers the problem

Maybe this can help.

The problem is _not_ triggered when using 'make defconfig'.
Comment 3 Lasse Kliemann 2009-04-05 15:19:44 UTC
Segfault does not occur when omitting '-ffreestanding'.

Segfault does not occur when using '-save-temps'.

When I add '-save-temps' to 'arch/x86/Makefile' in the same location in which '-ffreestanding' occurs, 'make' runs through. I have not tested whether the resulting kernel works.

Moreover, in that Makefile, it reads:

# temporary until string.h is fixed
KBUILD_CFLAGS += -ffreestanding

So, it appears that '-ffreestanding' is itself a workaround for something.

Another approach: obtain 'skbuff.i' via '-save-temps' and then copy it to 'net/core/skbuff.c'. Then 'make' will also run through.
Comment 4 Andrew Pinski 2009-04-22 23:39:14 UTC
Can you give the output of gcc -v?
Comment 5 Lasse Kliemann 2009-04-23 06:42:52 UTC
(In reply to comment #4)
> Can you give the output of gcc -v?
> 

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /package/host/localhost/sepbuilt/gcc41-4.1.2-01-03/src/unpack/gcc-4.1.2/configure --prefix=/package/host/localhost/sepbuilt/gcc41-4.1.2-01-03/prefix --libexecdir=/package/host/localhost/sepbuilt/gcc41-4.1.2-01-03/prefix/libexec --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-checking --disable-werror --enable-bootstrap --enable-languages=c,c++
Thread model: posix
gcc version 4.1.2

By the way, this gcc was compiled roughly following the instructions from the HLFS project. In particular, this includes the following patches:

http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-fstack_protector-1.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-strncat_chk-1.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-fortify_source-2.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-fpie-2.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-DW_CFA_val-1.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-Wno_overlength_strings-1.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-PR26864-1.patch
http://www.linuxfromscratch.org/patches/hlfs/svn/gcc-4.1.2-texinfo_fix-1.patch

I can go and try to reproduce with a vanilla gcc, if that helps.