public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp
@ 2014-05-16 13:28 psxlover at hotmail dot com
  2014-05-16 15:08 ` [Bug libgomp/61200] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: psxlover at hotmail dot com @ 2014-05-16 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

            Bug ID: 61200
           Summary: internal compiler error: Segmentation fault, assert &
                    openmp
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: psxlover at hotmail dot com
                CC: jakub at gcc dot gnu.org

Created attachment 32807
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32807&action=edit
Minimal test case

When trying to compile attached file with "-fopenmp" I get a segmentation
fault.
Tried with gcc 4.4.5 (on debian squeeze), 4.8.2 (on cygwin, fedora 20 and
debian wheezy) and 4.9.0 and all of them crash.

The problem occurs when there is an assert in a parallel region containing a
variable and then you have a task with that variable as share and you access it
in any way.

The problem doesn't occur if the assert is not in a "#pragma omp parallel" or
if you change he following task to parallel, or if you remove the shared
directive from the task or finally if you don't access the variable inside the
task.

The assert call can contain anything as long as it contains the variable that
is accessed later in a task.

Here is the output of "./gcc-4.9.0/bin/gcc -v -save-temps -fopenmp
fopenmpSeg.c":


Using built-in specs.
COLLECT_GCC=./gcc-4.9.0/bin/gcc
COLLECT_LTO_WRAPPER=/home/psxlover/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/configure
--prefix=/home/psxlover/gcc-4.9.0 --disable-multilib
Thread model: posix
gcc version 4.9.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-mtune=generic'
'-march=x86-64' '-pthread'
 /home/psxlover/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1 -E
-quiet -v -D_REENTRANT fopenmpSeg.c -mtune=generic -march=x86-64 -fopenmp
-fpch-preprocess -o fopenmpSeg.i
ignoring nonexistent directory
"/home/psxlover/gcc-4.9.0/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/psxlover/gcc-4.9.0/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include
 /usr/local/include
 /home/psxlover/gcc-4.9.0/include
 /home/psxlover/gcc-4.9.0/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fopenmp' '-mtune=generic'
'-march=x86-64' '-pthread'
 /home/psxlover/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1
-fpreprocessed fopenmpSeg.i -quiet -dumpbase fopenmpSeg.c -mtune=generic
-march=x86-64 -auxbase fopenmpSeg -version -fopenmp -o fopenmpSeg.s
GNU C (GCC) version 4.9.0 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.0, GMP version 4.3.2, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.9.0 (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.0, GMP version 4.3.2, MPFR version 2.4.2, MPC
version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 24a1e3ed1d75ecc9aae55f188f0fd7ae
fopenmpSeg.c: In function ‘main’:
fopenmpSeg.c:8:28: internal compiler error: Segmentation fault
   assert(var == 1);

                            ^
0x8e103f crash_signal
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/toplev.c:337
0x7723e1 gimplify_expr(tree_node**, gimple_statement_base**,
gimple_statement_base**, bool (*)(tree_node*), int)
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/gimplify.c:8376
0x779cd0 gimple_regimplify_operands(gimple_statement_base*,
gimple_stmt_iterator*)
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/gimplify-me.c:172
0x82853b lower_omp_1
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10139
0x82853b lower_omp
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10151
0x82cca4 lower_omp_taskreg
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:9485
0x828dfe lower_omp_1
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10016
0x828dfe lower_omp
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10151
0x8292dc lower_omp_1
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10008
0x8292dc lower_omp
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10151
0x82ad6a execute_lower_omp
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10183
0x82ad6a execute
    /home/psxlover/Downloads/gcc4.9obj/../gcc-4.9.0/gcc/omp-low.c:10222
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
>From gcc-bugs-return-451763-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri May 16 13:31:28 2014
Return-Path: <gcc-bugs-return-451763-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 18257 invoked by alias); 16 May 2014 13:31:27 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 18203 invoked by uid 48); 16 May 2014 13:31:22 -0000
From: "christophe.lyon at st dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/59904] [ARM] tls-reload-1.c fails
Date: Fri, 16 May 2014 13:31:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: christophe.lyon at st dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59904-4-nN5T38ULbm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59904-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59904-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg01455.txt.bz2
Content-length: 769

https://gcc.gnu.org/bugzilla/show_bug.cgi?idY904

--- Comment #6 from christophe.lyon at st dot com ---
I have re-run the tests with trunk@210140 and older binutils (Sept 2013).

The test fails at compilation with target arm-none-linux-gnueabi, and
CFLAGS=-Os  -pie -fpie or -Os  -pie -fPIE in the following configurations:
--with-mode=arm --with-cpu=cortex-a9
--with-mode=arm --with-cpu=cortex-a9 RUNTESTFLAGS=-mthumb
--with-mode=thumb --with-cpu=cortex-a9
--with-mode=thumb --with-cpu=cortex-a9 RUNTESTFLAGS=-marm

The test compiles OK and fails at execution with
--with-mode=thumb --with-cpu=cortex-a9 RUNTESTFLAGS=-march=armv5t
(this is the ELF file I have attached)

The compiles and runs OK with
--with-mode=arm --with-cpu=cortex-a9 RUNTESTFLAGS=-march=armv5t


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
@ 2014-05-16 15:08 ` jakub at gcc dot gnu.org
  2014-10-03  7:30 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-05-16 15:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-05-16
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
More reduced testcase:
int
main ()
{
  int var = 1;
  #pragma omp parallel
    if (var != 1)
      __builtin_abort ();
  #pragma omp task shared(var)
    var = 2;
  return 0;
}

The problem is that previously non-addressable var needs to be turned into
addressable because it is shared in the task, where we can't use copy-in/out,
but by that time we have already processed the #pragma omp parallel and decided
to copy-in/out var there, but later on it is TREE_ADDRESSABLE and thus we
expect that copy-in/out is not used in that case.

Unfortunately, I believe we really have to force no copy-in/out in that case,
consider:
#include <omp.h>
#include <stdlib.h>
#include <unistd.h>

volatile int x;

void
foo ()
{
  int var = 1;
  int i;

  for (i = 0; i < 2; i++)
    {
      if (i == 1)
        {
          #pragma omp parallel
            if (x)
              var++;
            else
              {
                #pragma omp single
                  sleep (4);
              }
        }
      else
        {
          #pragma omp task shared(var)
          {
            sleep (2);
            var = 2;
          }
        }
    }
  #pragma omp taskwait
  if (var != 2)
    abort ();
}

int
main ()
{
  omp_set_nested (1);
  #pragma omp parallel
    #pragma omp single
      foo ();
  return 0;
}

If we decide to use copy-in/out in #pragma omp parallel for var, but the task
will be run in parallel with the #pragma omp parallel, then if the #pragma omp
parallel is entered before var = 2 is set in another thread, it will copy in
value 1, then var = 2 happens and if #pragma omp parallel finishes after that,
it will copy out the value it copied in (1) and the testcase will break, even
when there is actually no data-race originally (the compiler doesn't know the
parallel will not touch var at all).


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
  2014-05-16 15:08 ` [Bug libgomp/61200] " jakub at gcc dot gnu.org
@ 2014-10-03  7:30 ` jakub at gcc dot gnu.org
  2014-10-03  8:18 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-03  7:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Oct  3 07:29:42 2014
New Revision: 215835

URL: https://gcc.gnu.org/viewcvs?rev=215835&root=gcc&view=rev
Log:
    PR libgomp/61200
    * omp-low.c (taskreg_contexts): New variable.
    (scan_omp_parallel): Push newly created context into taskreg_contexts
    vector and move record layout code to finish_taskreg_scan.
    (scan_omp_task): Likewise.
    (finish_taskreg_scan): New function.
    (execute_lower_omp): Call finish_taskreg_scan on all taskreg_contexts
    vector elements and release it.

    * c-c++-common/gomp/pr61200.c: New test.

    * testsuite/libgomp.c/pr61200.c: New test.

Added:
    trunk/gcc/testsuite/c-c++-common/gomp/pr61200.c
    trunk/libgomp/testsuite/libgomp.c/pr61200.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/omp-low.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgomp/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
  2014-05-16 15:08 ` [Bug libgomp/61200] " jakub at gcc dot gnu.org
  2014-10-03  7:30 ` jakub at gcc dot gnu.org
@ 2014-10-03  8:18 ` jakub at gcc dot gnu.org
  2014-10-03  8:24 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-03  8:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Oct  3 08:17:34 2014
New Revision: 215838

URL: https://gcc.gnu.org/viewcvs?rev=215838&root=gcc&view=rev
Log:
    PR libgomp/61200
    * omp-low.c (taskreg_contexts): New variable.
    (scan_omp_parallel): Push newly created context into taskreg_contexts
    vector and move record layout code to finish_taskreg_scan.
    (scan_omp_task): Likewise.
    (finish_taskreg_scan): New function.
    (execute_lower_omp): Call finish_taskreg_scan on all taskreg_contexts
    vector elements and release it.

    * c-c++-common/gomp/pr61200.c: New test.

    * testsuite/libgomp.c/pr61200.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/c-c++-common/gomp/pr61200.c
    branches/gcc-4_9-branch/libgomp/testsuite/libgomp.c/pr61200.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/omp-low.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/libgomp/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
                   ` (2 preceding siblings ...)
  2014-10-03  8:18 ` jakub at gcc dot gnu.org
@ 2014-10-03  8:24 ` jakub at gcc dot gnu.org
  2014-11-28 17:03 ` jakub at gcc dot gnu.org
  2014-11-28 17:13 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-10-03  8:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 4.9+ so far.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
                   ` (3 preceding siblings ...)
  2014-10-03  8:24 ` jakub at gcc dot gnu.org
@ 2014-11-28 17:03 ` jakub at gcc dot gnu.org
  2014-11-28 17:13 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28 17:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Fri Nov 28 17:03:01 2014
New Revision: 218165

URL: https://gcc.gnu.org/viewcvs?rev=218165&root=gcc&view=rev
Log:
    Backported from mainline
    2014-10-03  Jakub Jelinek  <jakub@redhat.com>

    PR libgomp/61200
    * omp-low.c (taskreg_contexts): New variable.
    (scan_omp_parallel): Push newly created context into taskreg_contexts
    vector and move record layout code to finish_taskreg_scan.
    (scan_omp_task): Likewise.
    (finish_taskreg_scan): New function.
    (execute_lower_omp): Call finish_taskreg_scan on all taskreg_contexts
    vector elements and release it.

    * c-c++-common/gomp/pr61200.c: New test.

    * testsuite/libgomp.c/pr61200.c: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/c-c++-common/gomp/pr61200.c
    branches/gcc-4_8-branch/libgomp/testsuite/libgomp.c/pr61200.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/omp-low.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/libgomp/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libgomp/61200] internal compiler error: Segmentation fault, assert & openmp
  2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
                   ` (4 preceding siblings ...)
  2014-11-28 17:03 ` jakub at gcc dot gnu.org
@ 2014-11-28 17:13 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-11-28 17:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61200

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 4.8.4+ and 4.9.2+.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-28 17:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16 13:28 [Bug libgomp/61200] New: internal compiler error: Segmentation fault, assert & openmp psxlover at hotmail dot com
2014-05-16 15:08 ` [Bug libgomp/61200] " jakub at gcc dot gnu.org
2014-10-03  7:30 ` jakub at gcc dot gnu.org
2014-10-03  8:18 ` jakub at gcc dot gnu.org
2014-10-03  8:24 ` jakub at gcc dot gnu.org
2014-11-28 17:03 ` jakub at gcc dot gnu.org
2014-11-28 17:13 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).