Bug 40388 - [4.5 Regression] another null pointer in remove_unreachable_regions
Summary: [4.5 Regression] another null pointer in remove_unreachable_regions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-06-09 13:03 UTC by David Binderman
Modified: 2009-07-12 20:23 UTC (History)
3 users (show)

See Also:
Host: x86_64-suse-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-07-12 18:32:53


Attachments
C++ source code (126.64 KB, text/plain)
2009-06-10 08:28 UTC, David Binderman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2009-06-09 13:03:50 UTC
I just tried to compile the Suse Factory package blocxx-2.1.0.342-124.7
with the GNU g++ version 4.5 snapshot 20090604.

The compiler said

SecureRand.cpp: In function 'void<unnamed>::rand_init_impl()':
SecureRand.cpp:667:7: 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.

Preprocessed source code attached. Flag -O2 required.

Here is valgrind helping out with a stack backtrace

==8611== Invalid read of size 8
==8611==    at 0x6EE6FF: remove_unreachable_regions (bitmap.h:225)
==8611==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

This bug seems to be different to # 40163.
Comment 1 Richard Biener 2009-06-09 14:27:14 UTC
Can you attach preprocessed source?
Comment 2 David Binderman 2009-06-10 08:28:01 UTC
Created attachment 17973 [details]
C++ source code
Comment 3 H.J. Lu 2009-06-10 12:00:54 UTC
It is caused by revision 146776:

http://gcc.gnu.org/ml/gcc-cvs/2009-04/msg01418.html
Comment 4 Volker Reichelt 2009-06-10 14:43:14 UTC
Confirmed. Reduced testcase (already crashes with "-O"):

======================================
struct A
{
  ~A();
};

struct B
{
  A* p;

  ~B()
  {
    if (p)
      delete p;
    delete p;
  }
};

struct C
{
  B* q;

  ~C()
  {
    try
    {
      delete q;
    }
    catch (...)
    {
    }
  }
};

void foo()
{
  C c1, c2;
}
======================================
Comment 5 Volker Reichelt 2009-06-10 15:50:58 UTC
Even shorter testcase:

==================
void foo();

struct A
{
  ~A()
  {
    try
    {
      foo();
      foo();
    }
    catch (...)
    {
    }
  }
};

void bar()
{
  A a1, a2;
}
==================
Comment 6 Richard Biener 2009-07-09 15:32:24 UTC
#1  0x00000000008c8613 in can_be_reached_by_runtime (contains_stmt=0x188ab30, 
    r=0x7ffff5fc33f0) at /space/rguenther/src/svn/trunk/gcc/except.c:569
569                 EXECUTE_IF_SET_IN_BITMAP (i->aka, 0, n, bi)
(gdb) p i->aka
$1 = (bitmap) 0x0
Comment 7 Jan Hubicka 2009-07-10 22:36:09 UTC
Subject: Re:  [4.5 Regression] another null pointer in remove_unreachable_regions

> 569                 EXECUTE_IF_SET_IN_BITMAP (i->aka, 0, n, bi)
> (gdb) p i->aka
> $1 = (bitmap) 0x0
oops, forgot about this issue.  Testing obvious patch checking for
i->aka being NULL.
Comment 8 Jan Hubicka 2009-07-11 19:08:13 UTC
Fixed.
Comment 9 H.J. Lu 2009-07-12 18:32:53 UTC
It doesn't work. On Linux/ia32, I got

FAIL: g++.dg/torture/pr40388.C  -O0  (test for excess errors)
FAIL: g++.dg/torture/pr40388.C  -O1  (test for excess errors)
FAIL: g++.dg/torture/pr40388.C  -O2  (test for excess errors)
FAIL: g++.dg/torture/pr40388.C  -O3 -fomit-frame-pointer  (test for excess errors)
FAIL: g++.dg/torture/pr40388.C  -O3 -g  (test for excess errors)
FAIL: g++.dg/torture/pr40388.C  -Os  (test for excess errors)
Comment 10 H.J. Lu 2009-07-12 18:33:39 UTC
The same failure happens on Linux/Intel64 and Linux/ia64.
Comment 11 Jason Merrill 2009-07-12 20:23:47 UTC
The testsuite failure was due to a double paste into the testcase; fixing that maxes it work.
Comment 12 Jan Hubicka 2009-07-12 22:44:07 UTC
Subject: Re:  [4.5 Regression] another null pointer in remove_unreachable_regions

> The testsuite failure was due to a double paste into the testcase; fixing that
> maxes it work.

Uh, double application of patch..
Thanks for fixing it!