Bug 61324

Summary: [5 Regression] ICE: SIGSEGV at ipa-comdats.c:321 with -fno-use-cxa-atexit -fkeep-inline-functions
Product: gcc Reporter: Zdenek Sojka <zsojka>
Component: ipaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: hubicka, ro, spop
Priority: P1 Keywords: ice-on-valid-code
Version: 5.0   
Target Milestone: 5.0   
Host: x86_64-pc-linux-gnu Target: x86_64-pc-linux-gnu
Build: Known to work: 4.9.1
Known to fail: 5.0 Last reconfirmed: 2014-11-19 00:00:00
Attachments: reduced testcase

Description Zdenek Sojka 2014-05-26 21:24:55 UTC
Created attachment 32857 [details]
reduced testcase

Compiler output:
$ gcc -O -fno-use-cxa-atexit -fkeep-inline-functions testcase.C
==21710== Invalid read of size 8
==21710==    at 0x156AD6D: (anonymous namespace)::pass_ipa_comdats::execute(function*) (ipa-comdats.c:321)
==21710==    by 0xC15D37: execute_one_pass(opt_pass*) (passes.c:2180)
==21710==    by 0xC167CA: execute_ipa_pass_list(opt_pass*) (passes.c:2571)
==21710==    by 0x94CA46: compile() (cgraphunit.c:2093)
==21710==    by 0x94D484: finalize_compilation_unit() (cgraphunit.c:2338)
==21710==    by 0x72A27E: cp_write_global_declarations() (decl2.c:4632)
==21710==    by 0xD10B8C: compile_file() (toplev.c:562)
==21710==    by 0xD12BC4: toplev_main(int, char**) (toplev.c:1915)
==21710==    by 0x5A46BF4: (below main) (in /lib64/libc-2.17.so)
==21710==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==21710== 
testcase.C:11:4: internal compiler error: Segmentation fault
 S s;
    ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r210922 - ICE
4_9 r210572 - OK
Comment 1 Richard Biener 2014-11-19 13:41:21 UTC
Confirmed.
Comment 2 tbsaunde 2014-11-23 07:33:07 UTC
*** Bug 63855 has been marked as a duplicate of this bug. ***
Comment 3 H.J. Lu 2014-11-23 15:27:00 UTC
It is caused by r210597.
Comment 4 Jan Hubicka 2014-12-11 21:49:21 UTC
Author: hubicka
Date: Thu Dec 11 21:48:48 2014
New Revision: 218640

URL: https://gcc.gnu.org/viewcvs?rev=218640&root=gcc&view=rev
Log:

	PR ipa/61324
	* testsuite/g++.dg/pr61324.C: New testcase by Trevor Saunders.
	* testsuite/g++.dg/tm/pr51411-2.C: Update se the extern function is
	not eliminated early.
	* testsuite/gcc.target/i386/pr57756.c: Turn extern inline into static
	inline.

	* passes.c (execute_todo): Update call of remove_unreachable_nodes.
	* ipa-chkp.c (chkp_produce_thunks): Use TODO_remove_functions.
	* cgraphunit.c (symbol_table::process_new_functions): Add
	IPA_SSA_AFTER_INLINING.
	(ipa_passes): Update call of remove_unreachable_nodes.
	(symbol_table::compile): Remove call of remove_unreachable_nodes.
	* ipa-inline.c (inline_small_functions): Do not ICE with
	-flto-partition=none
	(ipa_inline): Update symtab->state; fix formatting
	update call of remove_unreachable_nodes.
	* cgraphclones.c (symbol_table::materialize_all_clones): Likewise.
	* cgraph.h (enum symtab_state): Add IPA_SSA_AFTER_INLINING.
	(remove_unreachable_nodes): Update.
	* ipa.c (process_references): Keep external references only
	when optimizing.
	(walk_polymorphic_call_targets): Keep possible polymorphic call
	target only when devirtualizing.
	(symbol_table::remove_unreachable_nodes): Remove BEFORE_INLINING_P
	parameter.
	(ipa_single_use): Update comment.
	* ipa-pure-const.c (cdtor_p): New function.
	(propagate_pure_const): Track if some cdtor was turned pure/const.
	(execute): Return TODO_remove_functions if needed.
	* ipa-comdats.c (ipa_comdats): Update comment.
	
	* lto.c (read_cgraph_and_symbols): Update call of
	remove_unreachable_nodes.
	(do_whole_program_analysis): Remove call of
	symtab->remove_unreachable_nodes

Added:
    trunk/gcc/testsuite/g++.dg/pr61324.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.h
    trunk/gcc/cgraphclones.c
    trunk/gcc/cgraphunit.c
    trunk/gcc/ipa-chkp.c
    trunk/gcc/ipa-comdats.c
    trunk/gcc/ipa-inline.c
    trunk/gcc/ipa-pure-const.c
    trunk/gcc/ipa.c
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto.c
    trunk/gcc/passes.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/tm/pr51411-2.C
    trunk/gcc/testsuite/gcc.target/i386/pr57756.c
Comment 5 Jan Hubicka 2014-12-15 03:54:12 UTC
*** Bug 63313 has been marked as a duplicate of this bug. ***
Comment 6 Jan Hubicka 2014-12-15 06:33:01 UTC
Fixed.
Comment 7 Jan Hubicka 2014-12-15 06:39:33 UTC
*** Bug 61283 has been marked as a duplicate of this bug. ***