Bug 59669 - ICE: SIGSEGV with #pragma omp declare simd linear
ICE: SIGSEGV with #pragma omp declare simd linear
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: middle-end
4.9.0
: P3 normal
: 4.9.0
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-03 21:16 UTC by Zdenek Sojka
Modified: 2014-01-08 15:38 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.9.0
Last reconfirmed: 2014-01-08 00:00:00


Attachments
reduced testcase (56 bytes, text/x-csrc)
2014-01-03 21:16 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2014-01-03 21:16:16 UTC
Created attachment 31567 [details]
reduced testcase

Compiler output:
$ gcc -fopenmp testcase.c
==16645== Invalid read of size 2
==16645==    at 0xA2AEDB: simd_clone_adjust(cgraph_node*) (tree.h:2916)
==16645==    by 0xA3C2FD: (anonymous namespace)::pass_omp_simd_clone::execute() (omp-low.c:11727)
==16645==    by 0xA58859: execute_one_pass(opt_pass*) (passes.c:2226)
==16645==    by 0xA590DA: execute_ipa_pass_list(opt_pass*) (passes.c:2604)
==16645==    by 0x79797A: compile() (cgraphunit.c:2200)
==16645==    by 0x7986A4: finalize_compilation_unit() (cgraphunit.c:2319)
==16645==    by 0x6482A3: c_write_global_declarations() (c-decl.c:10400)
==16645==    by 0xB4DE6C: compile_file() (toplev.c:561)
==16645==    by 0xB4FDF7: toplev_main(int, char**) (toplev.c:1887)
==16645==    by 0x5A439B4: (below main) (in /lib64/libc-2.16.so)
==16645==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==16645== 
testcase.c: In function 'foo.simdclone.0':
testcase.c:5: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.

$ gcc -v
Using built-in specs.
COLLECT_GCC=/mnt/svn/gcc-trunk/binary-latest/bin/gcc
COLLECT_LTO_WRAPPER=/mnt/svn/gcc-trunk/binary-206310-lto-fortran-checking-yes-rtl-df/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /mnt/svn/gcc-trunk//configure --enable-checking=yes,rtl,df --enable-languages=c,c++,lto,fortran --prefix=/mnt/svn/gcc-trunk/binary-206310-lto-fortran-checking-yes-rtl-df/ --without-cloog --without-ppl
Thread model: posix
gcc version 4.9.0 20140103 (experimental) (GCC) 

Tested revisions:
r206310 - crash
4.8 - ignoring #pragma omp declare
Comment 1 Marek Polacek 2014-01-08 12:30:52 UTC
We're trying to get the default definition for 'a', but it's NULL, and then calling has_zero_uses on it segvs.  So perhaps

--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -11587,7 +11587,7 @@ simd_clone_adjust (struct cgraph_node *node)
        tree def = ssa_default_def (cfun, orig_arg);
        gcc_assert (INTEGRAL_TYPE_P (TREE_TYPE (orig_arg))
                    || POINTER_TYPE_P (TREE_TYPE (orig_arg)));
-       if (!has_zero_uses (def))
+       if (def && !has_zero_uses (def))
          {
            iter1 = make_ssa_name (orig_arg, NULL);
            iter2 = make_ssa_name (orig_arg, NULL);
Comment 2 Marek Polacek 2014-01-08 15:37:37 UTC
Author: mpolacek
Date: Wed Jan  8 15:37:35 2014
New Revision: 206431

URL: http://gcc.gnu.org/viewcvs?rev=206431&root=gcc&view=rev
Log:
	PR middle-end/59669
	* omp-low.c (simd_clone_adjust): Don't crash if def is NULL.
testsuite/
	* gcc.dg/gomp/pr59669-1.c: New test.
	* gcc.dg/gomp/pr59669-2.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/gomp/pr59669-1.c
    trunk/gcc/testsuite/gcc.dg/gomp/pr59669-2.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Marek Polacek 2014-01-08 15:38:31 UTC
Fixed.