This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/19333] New: Compilation SEGFAULTs with -O1 -finline-functions on the x86_64 architecture.


The following test code

-- test.c -------------------------------------
extern short int aa[][];
extern short int ab[][];
extern short int ac[][];

static void f(short int t[][4], int A, int B, int C, int D)
{
        int i;
        for(i=0; i<256; ++i)
        {
                t[i][0] = i*A;
                t[i][1] = i*B;
                t[i][2] = i*C;
                t[i][3] = i*D;
        }
}

void g()
{
        f(aa, -1, 0, 0, 0);
        f(ab, 3, -1, 0, 0);
        f(ac, 6, 3, -1, 0);
}
-----------------------------------------------

when compiled with

-----------------------------------------------
gcc -O1 -finline-functions -S test.c -o test.s
-----------------------------------------------

using the following GCC

-----------------------------------------------
$ gcc -v
Using built-in specs.
Configured with: ../../../gcc-CVS-20050107/gcc-CVS-20050107/configure
--host=x86_64-pc-linux-gnu --prefix=/usr/local/opt/gcc-4.0
--exec-prefix=/usr/local/opt/gcc-4.0 --sysconfdir=/etc
--libdir=/usr/local/opt/gcc-4.0/lib64
--libexecdir=/usr/local/opt/gcc-4.0/libexec64 --sharedstatedir=/var
--localstatedir=/var --program-suffix=-4.0 --with-x-includes=/usr/X11R6/include
--with-x-libraries=/usr/X11R6/lib64 --enable-shared --enable-static
--with-gnu-as --with-gnu-ld --with-stabs --enable-threads=posix
--enable-version-specific-runtime-libs --disable-coverage
--enable-gather-detailed-mem-stats --disable-libgcj --disable-checking
--enable-multilib --with-x --enable-cmath --enable-libstdcxx-debug
--enable-fast-character --enable-hash-synchronization --with-system-zlib
--with-libbanshee --with-demangler-in-ld --with-arch=athlon64 --disable-libada
--enable-languages=c,c++,f95,objc
Thread model: posix
gcc version 4.0.0 20050107 (experimental)
-----------------------------------------------

(i.e., native gcc for the x86_64 architecture) SEGFAULTs in a following way:

-----------------------------------------------
$ gcc -v -S -O1 -finline-functions test.c -o test.s
Using built-in specs.
Configured with: ../../../gcc-CVS-20050107/gcc-CVS-20050107/configure
--host=x86_64-pc-linux-gnu --prefix=/usr/local/opt/gcc-4.0
--exec-prefix=/usr/local/opt/gcc-4.0 --sysconfdir=/etc
--libdir=/usr/local/opt/gcc-4.0/lib64
--libexecdir=/usr/local/opt/gcc-4.0/libexec64 --sharedstatedir=/var
--localstatedir=/var --program-suffix=-4.0 --with-x-includes=/usr/X11R6/include
--with-x-libraries=/usr/X11R6/lib64 --enable-shared --enable-static
--with-gnu-as --with-gnu-ld --with-stabs --enable-threads=posix
--enable-version-specific-runtime-libs --disable-coverage
--enable-gather-detailed-mem-stats --disable-libgcj --disable-checking
--enable-multilib --with-x --enable-cmath --enable-libstdcxx-debug
--enable-fast-character --enable-hash-synchronization --with-system-zlib
--with-libbanshee --with-demangler-in-ld --with-arch=athlon64 --disable-libada
--enable-languages=c,c++,f95,objc
Thread model: posix
gcc version 4.0.0 20050107 (experimental)
 /usr/local/opt/gcc-4.0/libexec64/gcc/x86_64-pc-linux-gnu/4.0.0/cc1 -quiet -v
-iprefix
/usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/x86_64-pc-linux-gnu/4.0.0/
test.c -quiet -dumpbase test.c -march=athlon64 -auxbase-strip test.s -O1
-version -finline-functions -o test.s
ignoring nonexistent directory
"/usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/x86_64-pc-linux-gnu/4.0.0/include"
ignoring nonexistent directory
"/usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/x86_64-pc-linux-gnu/4.0.0/../../../../x86_64-pc-linux-gnu/include"
ignoring nonexistent directory
"/usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/../../../../x86_64-pc-linux-gnu/include"
ignoring duplicate directory "/usr/local/include"
  as it is a non-system directory that duplicates a system directory
ignoring duplicate directory
"/usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/opt/gcc-4.0/include
 /usr/local/opt/gcc-4.0/lib64/gcc/x86_64-pc-linux-gnu/4.0.0/include
 /usr/include
End of search list.
GNU C version 4.0.0 20050107 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.0.0 20050107 (experimental).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=63859
test.c: In function âgâ:
test.c:18: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
$
-----------------------------------------------

It also segaults when the "-O1 -finline-functions" is changed for
"-O2 -finline-functions" or for "-O3".
I also tried to replace the -O1 with the following options "-fdefer-pop
-fmerge-constants -fthread-jumps -floop-optimize -fif-conversion
-fif-conversion2 -fdelayed-branch -fguess-branch-probability -fcprop-registers",
which is supposed to be equivalent to the -O1 according to the gcc.info file,
but surprisingly enough it passes without the SEGFAULT (so my guess is -O1 is
not equivalent to those options). It also passes, when either of following
conditions occurs:

1) Line 21 in the source is changed from "f(ac, 6, 3, -1, 0)" to "f(ac, 0, 3,
-1, 0)".
2) Line 3 and 21 in the source is commented out.
3) All "short int" types in the source are changed to "int".
4) You compile without the "-finline-functions".
5) You replace the "-O1" with "-O0".
6) You compile with the GCC compiled from the same sources as the x86_64 one
mentioned above, but when you compile it as a native compiler on the
i686-pc-linux-gnu architecture, i.e. the following (with exactly the same
compilation options, of course):

-----------------------------------------------
$ gcc -v
Using built-in specs.
Configured with: ../../../gcc-CVS-20050107/gcc-CVS-20050107/configure
--host=i686-pc-linux-gnu --prefix=/usr/local/opt/gcc-4.0
--exec-prefix=/usr/local/opt/gcc-4.0 --sysconfdir=/etc
--libdir=/usr/local/opt/gcc-4.0/lib --libexecdir=/usr/local/opt/gcc-4.0/libexec
--sharedstatedir=/var --localstatedir=/var --program-suffix=-4.0
--with-x-includes=/usr/X11R6/include --with-x-libraries=/usr/X11R6/lib
--enable-shared --enable-static --with-gnu-as --with-gnu-ld --with-stabs
--enable-threads=posix --enable-version-specific-runtime-libs --disable-coverage
--enable-gather-detailed-mem-stats --disable-libgcj --disable-checking
--enable-multilib --with-x --enable-cmath --enable-libstdcxx-debug
--enable-fast-character --enable-hash-synchronization --with-system-zlib
--with-libbanshee --with-demangler-in-ld --with-arch=athlon-xp --enable-libada
--enable-languages=c,c++,f95,objc,ada
Thread model: posix
gcc version 4.0.0 20050107 (experimental)
$
-----------------------------------------------

BTW. I also tried to compile with the same native x86_64 for different targets,
but the SEGFAULT is still there.

-- 
           Summary: Compilation SEGFAULTs with -O1 -finline-functions on the
                    x86_64 architecture.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drab at kepler dot fjfi dot cvut dot cz
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19333


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]