Bug 32018

Summary: [4.3 Regression] ICE on optimization
Product: gcc Reporter: Daniel Franke <dfranke>
Component: middle-endAssignee: Zdenek Dvorak <rakdver>
Severity: normal CC: christian.joensson, gcc-bugs, pinskia, rakdver, tobias.burnus
Priority: P3 Keywords: ice-on-valid-code, patch
Version: 4.3.0   
Target Milestone: 4.3.0   
URL: http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01500.html
Host: Target: i686-pc-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed: 2007-05-21 12:56:28
Bug Depends on:    
Bug Blocks: 29975    
Attachments: Described test case.

Description Daniel Franke 2007-05-21 12:32:47 UTC
Attached code from CP2K crashes f951 on i686-pc-linux-gnu if these flags
    FCFLAGS="-c -O2 -ftree-vectorize -msse2"
are specified. All of them are necessary, omitting any will avoid the segfault.

The crash seems to be related to the length of the subroutine. Further reducing the number of initializations avoid the segfault as well.

(gdb) run -O2  -ftree-vectorize -msse2 periodic_table.f90
Starting program: /h/franke/packages/i686-pc-linux-gnu/gcc/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 -O2  -ftree-vectorize -msse2 periodic_table.f90
Analyzing compilation unit
Performing interprocedural optimizations
 <visibility> <early_local_cleanups> <inline> <static-var> <pure-const> <type-escape-var>Assembling functions:
 init_periodic_table {GC 5333k ->
Program received signal SIGSEGV, Segmentation fault.
0x080f7413 in ggc_set_mark (p=0xa5a5a5a5) at ../../../svn/gcc/gcc/ggc-page.c:605
605       return base[L1][L2];
(gdb) bt
#0  0x080f7413 in ggc_set_mark (p=0xa5a5a5a5) at ../../../svn/gcc/gcc/ggc-page.c:605
#1  0x08253d98 in gt_ggc_mx_loop (x_p=0xb7ac5c94) at gtype-desc.c:302
#2  0x08253e00 in gt_ggc_mx_loop (x_p=0xb78d32e0) at gtype-desc.c:311
#3  0x08253de2 in gt_ggc_mx_loop (x_p=0xb7a9d114) at gtype-desc.c:309
#4  0x08253c83 in gt_ggc_mx_basic_block_def (x_p=0xb7a99ca8) at gtype-desc.c:825
#5  0x08253d19 in gt_ggc_mx_tree_ann_d (x_p=0xb7bc8b2c) at gtype-desc.c:703
#6  0x080b14bf in gt_ggc_mx_lang_tree_node (x_p=0xb7dbfac4) at ./gt-fortran-f95-lang.h:358
#7  0x0824c99e in gt_ggc_mx_cgraph_edge (x_p=0xb7c09c98) at gtype-desc.c:159
#8  0x0824c98f in gt_ggc_mx_cgraph_edge (x_p=0xb7c09ccc) at gtype-desc.c:158
#9  0x0824c81c in gt_ggc_mx_cgraph_node (x_p=0xb7d5e780) at gtype-desc.c:183
#10 0x0824ca8f in gt_ggc_m_P11cgraph_node4htab (x_p=0xb7dc2a14) at gtype-desc.c:1931
#11 0x0822bf09 in ggc_mark_roots () at ../../../svn/gcc/gcc/ggc-common.c:118
#12 0x080f7e38 in ggc_collect () at ../../../svn/gcc/gcc/ggc-page.c:1906
#13 0x0828112a in execute_one_pass (pass=0x87af720) at ../../../svn/gcc/gcc/passes.c:1087
#14 0x082812af in execute_pass_list (pass=0x87af720) at ../../../svn/gcc/gcc/passes.c:1117
#15 0x082812c2 in execute_pass_list (pass=0x87af620) at ../../../svn/gcc/gcc/passes.c:1118
#16 0x082812c2 in execute_pass_list (pass=0x87aee60) at ../../../svn/gcc/gcc/passes.c:1118
#17 0x08359f4c in tree_rest_of_compilation (fndecl=0xb7d5e680) at ../../../svn/gcc/gcc/tree-optimize.c:406
#18 0x084b3cf0 in cgraph_expand_function (node=0xb7d5e780) at ../../../svn/gcc/gcc/cgraphunit.c:1086
#19 0x084b6415 in cgraph_optimize () at ../../../svn/gcc/gcc/cgraphunit.c:1155
#20 0x080aeacc in gfc_be_parse_file (set_yydebug=0) at ../../../svn/gcc/gcc/fortran/f95-lang.c:307
#21 0x083004a8 in toplev_main (argc=5, argv=0xbf88fe24) at ../../../svn/gcc/gcc/toplev.c:1051
#22 0x080f263f in main (argc=Cannot access memory at address 0xc
) at ../../../svn/gcc/gcc/main.c:35


Analyzing compilation unit
Performing interprocedural optimizations
 <visibility> <early_local_cleanups> <inline> <static-var> <pure-const> <type-escape-var>Assembling functions:
 init_periodic_table {GC 5333k -> ==22375== Invalid read of size 4
==22375==    at 0x80F7413: ggc_set_mark (ggc-page.c:605)
==22375==  Address 0x2968 is not stack'd, malloc'd or (recently) free'd
Comment 1 Daniel Franke 2007-05-21 12:33:51 UTC
Created attachment 13594 [details]
Described test case.
Comment 2 Zdenek Dvorak 2007-05-22 22:58:14 UTC
Patch: http://gcc.gnu.org/ml/gcc-patches/2007-05/msg01500.html
Comment 3 Tobias Burnus 2007-05-24 12:47:25 UTC
*** Bug 32006 has been marked as a duplicate of this bug. ***
Comment 4 Zdenek Dvorak 2007-05-24 15:02:29 UTC
Subject: Bug 32018

Author: rakdver
Date: Thu May 24 14:02:12 2007
New Revision: 125024

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=125024
	PR middle-end/32018
	* tree-ssa-threadupdate.c (thread_through_loop_header): Use
	(thread_through_all_blocks): Call initialize_original_copy_tables
	and free_original_copy_tables.
	* cfgloopmanip.c (duplicate_loop, duplicate_loop_to_header_edge):
	Use set_loop_copy.
	* tree-cfg.c (tree_duplicate_sese_region): Ditto.
	* cfghooks.c (duplicate_block): Use get_loop_copy.
	* cfg.c: Include cfgloop.h.
	(loop_copy): New hash table.
	(initialize_original_copy_tables): Initialize loop_copy table.
	(free_original_copy_tables): Free loop_copy table.
	(copy_original_table_clear, copy_original_table_set,
	set_loop_copy, get_loop_copy): New functions.
	(set_bb_original, set_bb_copy): Use copy_original_table_set.
	* cfgloop.h (struct loop): Remove copy field.
	* Makefile.in (cfg.o): Add CFGLOOP_H dependency.
	* basic-block.h (set_loop_copy, get_loop_copy): Declare.


Comment 5 Andrew Pinski 2007-05-25 07:17:15 UTC