Bug 30558 - ICE with OpenMP and exceptions
Summary: ICE with OpenMP and exceptions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, openmp
Depends on:
Blocks:
 
Reported: 2007-01-23 15:58 UTC by Mario Emmenlauer
Modified: 2007-04-26 08:47 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-04-24 18:04:40


Attachments
reduced testcase (688 bytes, text/plain)
2007-01-23 23:43 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mario Emmenlauer 2007-01-23 15:58:03 UTC
The following small program gives an segmentation fault when compiled like this:
extgccsrc> g++ -Wall -fopenmp -O2 -I$POLDEST/ext/include -L$POLDEST/ext/lib -otest test.cc -lblitz -lgomp -lm
test2.cc: In function ‘int main()’:
test2.cc:7: internal compiler error: Segmentation fault

When removing the 'try-catch'-part it works fine.

----
#include <iostream>
#include <blitz/array.h>

int main()
{
  try
  {
    blitz::Array<blitz::TinyVector<float,3>,3> gradients(100,1,1);
    gradients = blitz::TinyVector<float,3>(0,0,0);

#pragma omp parallel for
    for( int lev = 0; lev < 100; ++lev)
    {
      blitz::TinyVector<int,3> pos( lev,1,1);
      blitz::TinyVector<float,3> normGradForward = 
              gradients(pos);

      blitz::TinyVector<float,3> normGradLeft =
              blitz::cross( normGradForward, normGradForward);
    }
  }
  catch( std::exception& err)
  {
    std::cerr << err.what() << std::endl
            << "try -h for help\n";
  }

  return 0;
}
----

Here my specs:

extgccsrc> gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: [...]/extgccsrc/gcc-4.2-20070117/configure --enable-languages=c,c++ --prefix=[...]/extgcc-x86_64_gcc4 --enable-shared --with-system-zlib --enable-threads=posix --enable-nls --enable-__cxa_atexit --without-included-gettext --enable-clocale=gnu --enable-libstdcxx-debug --enable-debug --with-mpfr=[...]/extgcc-x86_64_gcc4 --with-gmp=[...]/extgcc-x86_64_gcc4 --enable-checking=release --disable-multilib --disable-werror --enable-bootstrap
Thread model: posix
gcc version 4.2.0 20070117 (prerelease)
Comment 1 Andrew Pinski 2007-01-23 16:27:12 UTC
Can you attach the preprocessed source?
Comment 2 Mario Emmenlauer 2007-01-23 17:22:40 UTC
The uncompressed preprocessed source is 1,7MB (unless I'm doing something wrong here, it's just the -E flag to the usual compiler call, right?).
I uploaded it to http://data.marssoft.de/attachment-bug-30558.bz2

Thanks.
Comment 3 Richard Biener 2007-01-23 21:19:55 UTC
reducing.
Comment 4 Richard Biener 2007-01-23 23:43:53 UTC
Created attachment 12944 [details]
reduced testcase
Comment 5 Richard Biener 2007-01-23 23:46:37 UTC
Confirmed.
Comment 6 Mario Emmenlauer 2007-02-21 20:31:57 UTC
Just to note: I can confirm the bug for x86-architecture as well.
Comment 7 Jakub Jelinek 2007-04-24 12:45:26 UTC
Even more reduced testcase:
static int s = 6;

template <typename T> struct F
{
  ~F () {}
  F (T x) {}
  const T &operator[] (unsigned i) const { return s; }
};

template <typename T> F<T> foo (const F<T> &x)
{
  return F<T> (x[1]);
}

static F<int> z = 6;

struct G
{
  G () { bar (2); }
  F<int> &operator () (F<int> x) { return z; }
  void bar (int);
};

int
main ()
{
  try
  {
    G g;
#pragma omp parallel for
    for (int i = 0; i < 10; ++i)
      {
        F<int> j (i);
        F<int> f = g (j);
        F<int> h = foo (f);
      }
  }
  catch (int &e)
  {
  }
}
Comment 8 Jakub Jelinek 2007-04-26 08:29:57 UTC
Subject: Bug 30558

Author: jakub
Date: Thu Apr 26 08:29:46 2007
New Revision: 124177

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124177
Log:
	PR tree-optimization/30558
	* tree-eh.c (lower_eh_filter): If EH_FILTER_MUST_NOT_THROW
	clear this_state.prev_try.

	* g++.dg/gomp/pr30558.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/gomp/pr30558.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-eh.c

Comment 9 Jakub Jelinek 2007-04-26 08:35:38 UTC
Subject: Bug 30558

Author: jakub
Date: Thu Apr 26 08:35:28 2007
New Revision: 124179

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124179
Log:
	PR tree-optimization/30558
	* tree-eh.c (lower_eh_filter): If EH_FILTER_MUST_NOT_THROW
	clear this_state.prev_try.

	* g++.dg/gomp/pr30558.C: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/gomp/pr30558.C
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/tree-eh.c

Comment 10 Jakub Jelinek 2007-04-26 08:47:25 UTC
Fixed (4.3/4.2/4.1-rh).