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

             Bug #: 53992
           Summary: Combining -fopenmp and -fgnu-tm results in segfault or
                    misbehaving binaries
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ha...@debian.org


Created attachment 27808
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27808
Preprocessed source

Hi,
is the combination of -fopenmp and -fgnu-tm supported? Otherwise maybe some
error message explaining that it's not would be appropriate? Attached is a case
that makes gcc segfault:


$ gcc -v -fopenmp -fgnu-tm  min.c && ./a.out 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.1-2'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.1 (Debian 4.7.1-2) 
COLLECT_GCC_OPTIONS='-v' '-fopenmp' '-fgnu-tm' '-mtune=generic' '-march=x86-64'
'-pthread' '-pthread'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1 -quiet -v -imultiarch x86_64-linux-gnu
-D_REENTRANT min.c -quiet -dumpbase min.c -mtune=generic -march=x86-64 -auxbase
min -version -fopenmp -fgnu-tm -o /tmp/ccsCNMGH.s
GNU C (Debian 4.7.1-2) version 4.7.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.1, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.4.
warning: MPFR header version 3.1.0-p10 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.7.1-2) version 4.7.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.1, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.4.
warning: MPFR header version 3.1.0-p10 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9e08a85d4bf68460be9df04a431a25b0
min.c: In function ‘main’:
min.c:16:5: warning: incompatible implicit declaration of built-in function
‘printf’ [enabled by default]
min.c: In function ‘main._omp_fn.0’:
min.c:8:13: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
Preprocessed source stored into /tmp/cczZfnZg.out file, please attach this to
your bugreport.


If -O3 is enabled a binary is produced, but it misbehaves:

$ gcc -v -fopenmp -fgnu-tm  -O3 min.c 
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.1-2'
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.1 (Debian 4.7.1-2) 
COLLECT_GCC_OPTIONS='-v' '-fopenmp' '-fgnu-tm' '-O3' '-mtune=generic'
'-march=x86-64' '-pthread' '-pthread'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1 -quiet -v -imultiarch x86_64-linux-gnu
-D_REENTRANT min.c -quiet -dumpbase min.c -mtune=generic -march=x86-64 -auxbase
min -O3 -version -fopenmp -fgnu-tm -o /tmp/ccwYfizG.s
GNU C (Debian 4.7.1-2) version 4.7.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.1, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.4.
warning: MPFR header version 3.1.0-p10 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.7.1-2) version 4.7.1 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.1, GMP version 5.0.5, MPFR version 3.1.0-p10,
MPC version 0.9
warning: GMP header version 5.0.5 differs from library version 5.0.4.
warning: MPFR header version 3.1.0-p10 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9e08a85d4bf68460be9df04a431a25b0
min.c: In function ‘main’:
min.c:16:5: warning: incompatible implicit declaration of built-in function
‘printf’ [enabled by default]
COLLECT_GCC_OPTIONS='-v' '-fopenmp' '-fgnu-tm' '-O3' '-mtune=generic'
'-march=x86-64' '-pthread' '-pthread'
 as -v --64 -o /tmp/cc3HGMmf.o /tmp/ccwYfizG.s
GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.22
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/
Reading specs from /usr/lib/gcc/x86_64-linux-gnu/4.7/libgomp.spec
Reading specs from /usr/lib/gcc/x86_64-linux-gnu/4.7/libitm.spec
COLLECT_GCC_OPTIONS='-v' '-fopenmp' '-fgnu-tm' '-O3' '-mtune=generic'
'-march=x86-64' '-pthread' '-pthread'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2 --sysroot=/ --build-id
--no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker
/lib64/ld-linux-x86-64.so.2
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.7
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. /tmp/cc3HGMmf.o -lgomp -litm -lgcc
--as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o

$ ./a.out 
10000

Expected result was -9999

Reply via email to