Bug 44545 - [4.5 Regression] internal compiler error: in remove_unreachable_handlers, at tree-eh
Summary: [4.5 Regression] internal compiler error: in remove_unreachable_handlers, at ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P2 normal
Target Milestone: 4.5.2
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on: 45232
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-15 16:20 UTC by gxgjyyozme
Modified: 2010-11-16 14:17 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.4, 4.6.0
Known to fail:
Last reconfirmed: 2010-06-16 09:07:16


Attachments
Instance of source code which causes crash. (30.99 KB, application/octet-stream)
2010-06-15 16:22 UTC, gxgjyyozme
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gxgjyyozme 2010-06-15 16:20:15 UTC
A combination of options can yield the error:
internal compiler error: in remove_unreachable_handlers, at tree-eh.c

To produce the error, g++ is invoked thus:
g++ -c -pipe --trapv --non-call-exceptions --stack-check -O2

Aside from -pipe and -O2, which can be further decomposed, the options are the minimal set to produce the error in this case.

Build from 
URL: svn://gcc.gnu.org/svn/gcc/branches/gcc-4_5-branch
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 160774

unset LDFLAGS
export CFLAGS=-pipe
export CXXFLAGS=-pipe
configure --enable-languages=c++
make bootstrap-lean

See attachment for source code of test case.
Taken from geany/scintilla.
Comment 1 gxgjyyozme 2010-06-15 16:22:11 UTC
Created attachment 20917 [details]
Instance of source code which causes crash.

from geany/scintilla
Comment 2 Richard Biener 2010-06-16 09:07:15 UTC
CallTip.cxx: In member function 'void CallTip::DrawChunk(Surface*, int&, const char*, int, int, int, PRectangle, bool, bool)':
CallTip.cxx:87:6: error: control flow in the middle of basic block 64
CallTip.cxx:87:6: internal compiler error: verify_flow_info failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Reducing.
Comment 3 Richard Biener 2010-06-16 09:30:48 UTC
class CallTip {
    int tabSize;
    int DrawChunk(int &x);
    int NextTabPos(int x);
};
int CallTip::NextTabPos(int x) 
{
    if (tabSize > 0) {
        x -= 5;
        x = (x + tabSize) / tabSize;
    }
}
int CallTip::DrawChunk(int &x) 
{
    const int numEnds = 10;
    int ends[numEnds + 2];
    return NextTabPos(x);
}
Comment 4 Andrew Pinski 2010-06-29 22:04:29 UTC
Reduced even further:
int DrawChunk(int *tabSize, int x) 
{
    const int numEnds = 10;
    int ends[numEnds + 2];
    if (*tabSize > 0) {
        x -= 5;
        x = (x + *tabSize) / *tabSize;
    }
}
--- CUT ---

Compile with -O2 -fstack-check  -fnon-call-exceptions  -ftrapv -fexceptions (the last option is needed for C front-end).  As far as I can tell the reassoication pass causes the ICE.
Comment 5 Andrew Pinski 2010-06-29 22:09:35 UTC
(gdb) p debug_bb_n(6)
;; basic block 6, loop depth 0, count 0
;; prev block 5, next block 7
;; pred:       5 [100.0%]  (fallthru,exec)
;; succ:       9 (eh,exec) 7 [100.0%]  (fallthru,exec)
<bb 6>:
D.1986_12 = D.1986_7;
x_10 = D.1986_7 + x_9(D);
D.1989_14 = x_10 + -5;


Yep, the assignment to x_10 can trap which means it can throw an exception which reassociation needs to be corrected/turned off for non call exceptions with trapv turned on.
Comment 6 Richard Biener 2010-07-31 09:29:54 UTC
GCC 4.5.1 is being released, adjusting target milestone.
Comment 7 Richard Biener 2010-11-16 11:48:10 UTC
Can't reproduce it on current trunk.  Looking at it on the branch.
Comment 8 Eric Botcazou 2010-11-16 12:06:42 UTC
> Can't reproduce it on current trunk.  Looking at it on the branch.

Try -fstack-check=generic on the trunk.
Comment 9 Richard Biener 2010-11-16 12:13:12 UTC
The fix for PR45232 fixed it on the trunk.
Comment 10 Richard Biener 2010-11-16 13:53:53 UTC
Author: rguenth
Date: Tue Nov 16 13:53:50 2010
New Revision: 166796

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166796
Log:
2010-11-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44545
	* tree-ssa-reassoc.c (linearize_expr_tree): Possibly throwing
	statements are not reassociatable.
	(reassociate_bb): Likewise.

	* gcc.dg/pr44545.c: New testcase.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/pr44545.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_5-branch/gcc/tree-ssa-reassoc.c
Comment 11 Richard Biener 2010-11-16 14:15:59 UTC
Author: rguenth
Date: Tue Nov 16 14:15:55 2010
New Revision: 166799

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166799
Log:
2010-11-16  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44545
	* tree-ssa-reassoc.c (linearize_expr_tree): Possibly throwing
	statements are not reassociatable.
	(reassociate_bb): Likewise.

	* gcc.dg/pr44545.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/pr44545.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-reassoc.c
Comment 12 Richard Biener 2010-11-16 14:17:33 UTC
Fixed.