Bug 54902 - [4.7 Regression], ICE (segfault) building on arm-linux-gnueabi
Summary: [4.7 Regression], ICE (segfault) building on arm-linux-gnueabi
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: 4.7.3
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-10-11 15:34 UTC by Matthias Klose
Modified: 2012-10-25 11:32 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-linux-gnueabi
Build:
Known to work: 4.6.3, 4.8.0
Known to fail: 4.7.2
Last reconfirmed: 2012-10-24 00:00:00


Attachments
preprocessed source (117.72 KB, application/x-xz)
2012-10-11 15:34 UTC, Matthias Klose
Details
gdb backtrace (852 bytes, text/x-log)
2012-10-23 05:35 UTC, zhenqiang.chen
Details
patch (874 bytes, patch)
2012-10-24 13:58 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2012-10-11 15:34:02 UTC
Created attachment 28426 [details]
preprocessed source

seen building the cone package on arm-linux-gnueabi, works with 4.6 branch, fails with 4.7.

g++-4.7 -c -g -O[123] myserver.ii
myserver.C: In static member function 'static bool myServer::eventloop(myServer::Callback*)':
myserver.C:168:6: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.

Program received signal SIGSEGV, Segmentation fault.
0x003b90ae in free_scc_vn() ()
(gdb) bt
#0 0x003b90ae in free_scc_vn() ()
#1 0x003aee44 in ?? ()
#2 0x003aee44 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
Comment 1 Richard Biener 2012-10-12 09:37:04 UTC
Please also check trunk.
Comment 2 Matthias Klose 2012-10-12 09:58:46 UTC
trunk 20120820 and 20121008 do work.
Comment 3 Mikael Pettersson 2012-10-13 15:39:25 UTC
I can reproduce the ICE with gcc-4.7.2 on armv5tel-linux-gnueabi, sparc64-linux -m32, x86_64-linux -m32, and m68k-linux.  I haven't checked any other targets.

The ICE stopped on trunk with Richard B's "Make gsi_remove return whether EH cleanup is required" patch in r186159:
http://gcc.gnu.org/ml/gcc-patches/2012-04/msg00202.html
http://gcc.gnu.org/ml/gcc-cvs/2012-04/msg00108.html

Backporting r186159 and the follow-up fix in r186164 to gcc-4.7.2 eliminates the ICE there for the four targets mentioned above.

The description of Richard's patch makes it sound more like a cleanup than a bug fix, so I'm not sure if it actually fixes the bug or just masks it.
Comment 4 zhenqiang.chen 2012-10-23 05:35:17 UTC
Created attachment 28512 [details]
gdb backtrace

Root cause:

PRE bases on the result of value numbering (run_scc_vn). At the end, it free_scc_vn. But before free_scc_vn, it might call cleanup_tree_cfg ();

  if (do_eh_cleanup || do_ab_cleanup)
    cleanup_tree_cfg ();

cleanup_tree_cfg might call make_ssa_name which might reuse some "name" from the FREE_SSANAMES list. If the VN_INFO of the "name" is NULL, free_scc_vn will "Segmentation fault".

Richard's patch makes "do_eh_cleanup" to false. So cleanup_tree_cfg is not called in PRE. Then no new ssa name will be created.

bt.log shows the gdb backtrace to create a new ssa name.
Comment 5 Richard Biener 2012-10-24 13:40:38 UTC
Mine.
Comment 6 Richard Biener 2012-10-24 13:58:50 UTC
Created attachment 28517 [details]
patch

Patch I am testing.
Comment 7 Richard Biener 2012-10-25 11:05:49 UTC
Author: rguenth
Date: Thu Oct 25 11:05:43 2012
New Revision: 192803

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192803
Log:
2012-10-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/54902
	* tree-ssa-pre.c (fini_pre): Return TODO.
	(execute_pre): Adjust.
	* tree-ssa-tailmerge.c (tail_merge_optimize): Delete unreachable
	blocks before computing dominators.

	* g++.dg/torture/pr54902.C: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/torture/pr54902.C
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/tree-ssa-pre.c
    branches/gcc-4_7-branch/gcc/tree-ssa-tail-merge.c
Comment 8 Richard Biener 2012-10-25 11:16:19 UTC
Author: rguenth
Date: Thu Oct 25 11:16:12 2012
New Revision: 192804

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192804
Log:
2012-10-25  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/54902
	* tree-ssa-pre.c (fini_eliminate): Return TODO.
	(do_pre): Adjust.
	(execute_fre): Likewise.
	* tree-ssa-tailmerge.c (tail_merge_optimize): Delete unreachable
	blocks before computing dominators.

	* g++.dg/torture/pr54902.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr54902.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-tail-merge.c
Comment 9 Richard Biener 2012-10-25 11:32:04 UTC
Fixed.