Bug 48611 - [4.6/4.7 Regression] ICE: SIGSEGV in remap_eh_region_nr (tree-inline.c:1194) with -Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop on basic code
Summary: [4.6/4.7 Regression] ICE: SIGSEGV in remap_eh_region_nr (tree-inline.c:1194) ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2011-04-14 18:40 UTC by Zdenek Sojka
Modified: 2011-05-10 06:32 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.6.1, 4.7.0
Last reconfirmed: 2011-04-18 13:31:02


Attachments
auto-reduced testcase (117 bytes, text/plain)
2011-04-14 18:40 UTC, Zdenek Sojka
Details
gcc46-pr48611.patch (329 bytes, patch)
2011-04-18 13:36 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2011-04-14 18:40:20 UTC
Created attachment 23986 [details]
auto-reduced testcase

$ gcc -Os -fopenmp -fexceptions -fno-tree-ccp -fno-tree-copy-prop testcase-min1.f90
==12201== Invalid read of size 4
==12201==    at 0xBD4B3F: remap_eh_region_nr.isra.81 (tree-inline.c:1194)
==12201==    by 0xBD8A59: remap_gimple_stmt (tree-inline.c:1444)
==12201==    by 0xBD97EF: copy_cfg_body (tree-inline.c:1540)
==12201==    by 0xBDB6B6: copy_body (tree-inline.c:2410)
==12201==    by 0xBDE493: optimize_inline_calls (tree-inline.c:3928)
==12201==    by 0xBB67A2: cgraph_early_inlining (ipa-inline.c:1642)
==12201==    by 0x87F305: execute_one_pass (passes.c:1555)
==12201==    by 0x87F5F4: execute_pass_list (passes.c:1610)
==12201==    by 0x87E80B: do_per_function_toporder (passes.c:1141)
==12201==    by 0x87FA95: execute_ipa_pass_list (passes.c:1927)
==12201==    by 0xBAC6DC: cgraph_optimize (cgraphunit.c:1789)
==12201==    by 0xBAC949: cgraph_finalize_compilation_unit (cgraphunit.c:1102)
==12201==    by 0x836BFC: write_global_declarations (langhooks.c:303)
==12201==    by 0x96CC99: toplev_main (toplev.c:591)
==12201==    by 0x644AB6C: (below main) (in /lib64/libc-2.11.3.so)
==12201==  Address 0x18 is not stack'd, malloc'd or (recently) free'd
==12201== 
testcase-min1.f90: In function 'main':
testcase-min1.f90:8:0: 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.
Comment 1 Jakub Jelinek 2011-04-18 12:15:25 UTC
Caused by
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162219
Comment 2 Jakub Jelinek 2011-04-18 13:36:23 UTC
Created attachment 24030 [details]
gcc46-pr48611.patch

While the bug is most probably elsewhere, I wonder why note_eh_region_may_contain_throw doesn't stop propagating on ERT_MUST_NOT_THROW regions.  In my understanding no exception is ever propagated out of those regions, the program would be terminated instead, so I wonder why we should be trying to handle thrown exceptions in the outer regions.

The patch makes the ICE go away, as we don't needlessly try to handle exceptions in the outer try {} finally {}.
Comment 3 Jakub Jelinek 2011-04-20 18:18:19 UTC
Author: jakub
Date: Wed Apr 20 18:18:16 2011
New Revision: 172783

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172783
Log:
	PR tree-optimization/48611
	* tree-eh.c (note_eh_region_may_contain_throw): Don't propagate
	beyond ERT_MUST_NOT_THROW region.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-eh.c
Comment 4 Jakub Jelinek 2011-04-20 18:19:50 UTC
Author: jakub
Date: Wed Apr 20 18:19:47 2011
New Revision: 172786

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172786
Log:
	PR tree-optimization/48611
	* tree-eh.c (note_eh_region_may_contain_throw): Don't propagate
	beyond ERT_MUST_NOT_THROW region.

Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-eh.c
Comment 5 Jakub Jelinek 2011-04-20 18:29:48 UTC
Fixed.
Comment 6 Jakub Jelinek 2011-05-10 06:08:23 UTC
Author: jakub
Date: Tue May 10 06:08:18 2011
New Revision: 173607

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173607
Log:
	PR tree-optimization/48611
	PR tree-optimization/48794
	* tree-eh.c (remove_unreachable_handlers): Don't remove regions
	referenced from RESX or EH_DISPATCH arguments.

	* gfortran.dg/gomp/pr48611.f90: New test.
	* gfortran.dg/gomp/pr48794.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/gomp/pr48611.f90
    trunk/gcc/testsuite/gfortran.dg/gomp/pr48794.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-eh.c
Comment 7 Jakub Jelinek 2011-05-10 06:32:04 UTC
Author: jakub
Date: Tue May 10 06:31:59 2011
New Revision: 173608

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173608
Log:
	PR tree-optimization/48611
	PR tree-optimization/48794
	* tree-eh.c (remove_unreachable_handlers): Don't remove regions
	referenced from RESX or EH_DISPATCH arguments.

	* gfortran.dg/gomp/pr48611.f90: New test.
	* gfortran.dg/gomp/pr48794.f90: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/gomp/pr48611.f90
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/gomp/pr48794.f90
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-eh.c