Bug 91231 - ICE in dwarf2out_inline_entry, at dwarf2out.c:27642
Summary: ICE in dwarf2out_inline_entry, at dwarf2out.c:27642
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-07-23 07:37 UTC by Martin Liška
Modified: 2019-07-23 12:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 9.1.0
Last reconfirmed: 2019-07-23 00:00:00


Attachments
ltrans file (308.97 KB, application/x-xz)
2019-07-23 07:37 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-07-23 07:37:40 UTC
Created attachment 46621 [details]
ltrans file

The ICE happens for opencv3 package. Unfortunately, I can't reduce that ICE as one can't use -shared -fPIC and so that I'm attaching ltrans file which is reasonable small.

$ lto1 -quiet -dumpdir ../../bin/ -dumpbase opencv_test_core.ltrans75 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mf16c -mavx -mfma -mavx2 -msse -msse2 -mtune=generic -march=x86-64 -auxbase-strip opencv_test_core.ltrans75.ltrans.o -g -g -O2 -O2 -O2 -O2 -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=format-security -Wshadow -Wuninitialized -Wimplicit-fallthrough=3 -Wno-strict-overflow -version -fno-openmp -fno-openacc -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -fsigned-char -fdiagnostics-show-option -fno-omit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fPIE -fltrans opencv_test_core.ltrans75.o -o opencv_test_core.ltrans75.s

during RTL pass: final
/home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h: In member function ‘test_interleave’:
/home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h:414470:39: internal compiler error: in dwarf2out_inline_entry, at dwarf2out.c:27642
0x9de450 dwarf2out_inline_entry
	../../gcc/dwarf2out.c:27642
0xa822a7 final_scan_insn_1
	../../gcc/final.c:2436
0xa832fe final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
	../../gcc/final.c:3153
0xa81349 final_1
	../../gcc/final.c:2021
0xa85f83 rest_of_handle_final
	../../gcc/final.c:4659
0xa861d4 execute
	../../gcc/final.c:4737

$ (gdb) bt
#0  fancy_abort (file=0x1d1a22e "../../gcc/dwarf2out.c", line=27642, function=0x1d2171d "dwarf2out_inline_entry") at ../../gcc/diagnostic.c:1607
#1  0x00000000009de451 in dwarf2out_inline_entry (block=<block 0x7ffff6c11060>) at ../../gcc/dwarf2out.c:27642
#2  0x0000000000a822a8 in final_scan_insn_1 (insn=0x7ffff6d46cb0, file=0x2916ea0, optimize_p=2, nopeepholes=0, seen=0x7fffffffd42c) at ../../gcc/final.c:2436
#3  0x0000000000a832ff in final_scan_insn (insn=0x7ffff6d46cb0, file=0x2916ea0, optimize_p=2, nopeepholes=0, seen=0x7fffffffd42c) at ../../gcc/final.c:3153
#4  0x0000000000a8134a in final_1 (first=0x7ffff6c900e0, file=0x2916ea0, seen=3, optimize_p=2) at ../../gcc/final.c:2021
#5  0x0000000000a85f84 in rest_of_handle_final () at ../../gcc/final.c:4659
#6  0x0000000000a861d5 in (anonymous namespace)::pass_final::execute (this=0x2910f80) at ../../gcc/final.c:4737
#7  0x0000000000da7558 in execute_one_pass (pass=<opt_pass* 0x2910f80 "final"(325)>) at ../../gcc/passes.c:2488
#8  0x0000000000da7860 in execute_pass_list_1 (pass=<opt_pass* 0x2910f80 "final"(325)>) at ../../gcc/passes.c:2574
#9  0x0000000000da7891 in execute_pass_list_1 (pass=<opt_pass* 0x2910aa0 "*all-late_compilation"(-1)>) at ../../gcc/passes.c:2575
#10 0x0000000000da7891 in execute_pass_list_1 (pass=<opt_pass* 0x290eda0 "*rest_of_compilation"(-1)>) at ../../gcc/passes.c:2575
#11 0x0000000000da78e9 in execute_pass_list (fn=0x7ffff77c36e0, pass=<opt_pass* 0x290b060 "fixup_cfg"(93)>) at ../../gcc/passes.c:2585
#12 0x000000000093dd5f in cgraph_node::expand (this=<cgraph_node * const 0x7ffff7767168 "test_interleave"/352129>) at ../../gcc/cgraphunit.c:2198
#13 0x000000000093e1f5 in expand_all_functions () at ../../gcc/cgraphunit.c:2336
#14 0x000000000093ec88 in symbol_table::compile (this=0x7ffff78fa100) at ../../gcc/cgraphunit.c:2687
#15 0x000000000085bd48 in lto_main () at ../../gcc/lto/lto.c:3415
#16 0x0000000000ef4ac6 in compile_file () at ../../gcc/toplev.c:456
#17 0x0000000000ef7717 in do_compile () at ../../gcc/toplev.c:2205
#18 0x0000000000ef79fc in toplev::main (this=0x7fffffffd7ae, argc=55, argv=0x7fffffffd8a8) at ../../gcc/toplev.c:2340
#19 0x0000000001c0817a in main (argc=55, argv=0x7fffffffd8a8) at ../../gcc/main.c:39

$ (gdb) p debug_tree(block)
 <block 0x7ffff6c11060 asm_written used
    vars <var_decl 0x7ffff6c02b40 this
        type <pointer_type 0x7ffff771b1f8 type <record_type 0x7ffff7711dc8 Data>
            readonly unsigned DI
            size <integer_cst 0x7ffff78f7b70 constant 64>
            unit-size <integer_cst 0x7ffff78f7b88 constant 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality>
        readonly unsigned DI /home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h:414470:39 size <integer_cst 0x7ffff78f7b70 64> unit-size <integer_cst 0x7ffff78f7b88 8>
        align:64 warn_if_not_align:0 context <function_decl 0x7ffff7706f00 test_interleave> abstract_origin <parm_decl 0x7ffff6c0f180 this>>
    supercontext <block 0x7ffff6b88f00 asm_written used
        vars <var_decl 0x7ffff6bfb120 data1 type <record_type 0x7ffff7711dc8 Data>
            addressable used TI /home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h:414470:39
            size <integer_cst 0x7ffff78f7bb8 constant 128>
            unit-size <integer_cst 0x7ffff78f7bd0 constant 16>
            align:128 warn_if_not_align:0 context <function_decl 0x7ffff7706f00 test_interleave>
            (mem/c:TI (plus:DI (reg/f:DI 19 frame)
        (const_int -48 [0xffffffffffffffd0])) [2 data1+0 S16 A128]) chain <var_decl 0x7ffff6bfb090 data2>>
        supercontext <function_decl 0x7ffff7706f00 test_interleave type <method_type 0x7ffff77049d8>
            addressable asm_written public static function-specific-target function-specific-opt autoinline QI /home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/core/test/test_intrin_utils.hpp:339:0 align:16 warn_if_not_align:0 context <namespace_decl 0x7ffff7703688 opt_SSE2> initial <block 0x7ffff6b88f00> result <result_decl 0x7ffff6b96078 D.8437>
            (mem:QI (symbol_ref:DI ("_ZN11opencv_test3hal9intrin1288opt_SSE27TheTestIN2cv8hal_SSE29v_int32x4EE15test_interleaveEv") [flags 0x3] <function_decl 0x7ffff7706f00 test_interleave>) [0  S1 A8]) arguments <parm_decl 0x7ffff6f17a00 this>
            struct-function 0x7ffff77c36e0>
        subblocks <block 0x7ffff6bfcf00 asm_written used vars <var_decl 0x7ffff6c02990 this> supercontext <block 0x7ffff6b88f00>
            subblocks <block 0x7ffff6c11000 asm_written used supercontext <block 0x7ffff6bfcf00>
                chain <block 0x7ffff6c61b40 asm_written used supercontext <block 0x7ffff6bfcf00>
                    chain <block 0x7ffff6c61c00 asm_written used supercontext <block 0x7ffff6bfcf00>
                        chain <block 0x7ffff6c61d80 asm_written used supercontext <block 0x7ffff6bfcf00> abstract_origin <block 0x7ffff6bfcf60>>
                        abstract_origin <block 0x7ffff6bfcf60 supercontext <function_decl 0x7ffff771ae00 __conv_op > abstract_origin <block 0x7ffff6bfcf60>>> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>>
            chain <block 0x7ffff6c11120 asm_written used vars <var_decl 0x7ffff6c02cf0 this> supercontext <block 0x7ffff6b88f00>
                subblocks <block 0x7ffff6c11180 asm_written used supercontext <block 0x7ffff6c11120>
                    chain <block 0x7ffff6c61f00 used supercontext <block 0x7ffff6c11120>
                        chain <block 0x7ffff69a70c0 used supercontext <block 0x7ffff6c11120> chain <block 0x7ffff69a7180> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>> chain <block 0x7ffff6c11060> abstract_origin <function_decl 0x7ffff771ae00 __conv_op >> abstract_origin <function_decl 0x7ffff771ae00 __conv_op >>>
    subblocks <block 0x7ffff6c110c0 asm_written used supercontext <block 0x7ffff6c11060>
        chain <block 0x7ffff6c61cc0 asm_written used supercontext <block 0x7ffff6c11060>
            chain <block 0x7ffff6c61e40 used supercontext <block 0x7ffff6c11060>
                chain <block 0x7ffff69a7000 used supercontext <block 0x7ffff6c11060> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>> abstract_origin <block 0x7ffff6bfcf60>>
    chain <block 0x7ffff6c61ae0 asm_written used
        vars <var_decl 0x7ffff6c02990 this type <pointer_type 0x7ffff771b1f8>
            readonly unsigned DI /home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h:414470:39 size <integer_cst 0x7ffff78f7b70 64> unit-size <integer_cst 0x7ffff78f7b88 8>
            align:64 warn_if_not_align:0 context <function_decl 0x7ffff7706f00 test_interleave> abstract_origin <parm_decl 0x7ffff6c0f180 this>> supercontext <block 0x7ffff6b88f00>
        chain <block 0x7ffff6bfc420 asm_written used vars <var_decl 0x7ffff6bfb5a0 this> supercontext <block 0x7ffff6b88f00>
            subblocks <block 0x7ffff6bfc480 asm_written used supercontext <block 0x7ffff6bfc420>
                subblocks <block 0x7ffff6bfc4e0 asm_written used vars <var_decl 0x7ffff6bfb630 i> supercontext <block 0x7ffff6bfc480>
                    abstract_origin <block 0x7ffff6bfc060 vars <var_decl 0x7ffff6bfb1b0 i>
                        supercontext <block 0x7ffff6bfc000 supercontext <block 0x7ffff6b88f60> subblocks <block 0x7ffff6bfc060> abstract_origin <block 0x7ffff6bfc000>> abstract_origin <block 0x7ffff6bfc060>>>
                abstract_origin <block 0x7ffff6b88f60 supercontext <function_decl 0x7ffff771ad00 __ct > subblocks <block 0x7ffff6bfc000> abstract_origin <block 0x7ffff6b88f60>>>
            chain <block 0x7ffff6bfc300 asm_written used vars <var_decl 0x7ffff6bfb480 this> supercontext <block 0x7ffff6b88f00>
                chain <block 0x7ffff6bfc1e0 asm_written used vars <var_decl 0x7ffff6bfb360 this> supercontext <block 0x7ffff6b88f00>
                    chain <block 0x7ffff6bfc0c0 asm_written used vars <var_decl 0x7ffff6bfb240 this> supercontext <block 0x7ffff6b88f00>
                        chain <block 0x7ffff6bfccc0 asm_written used vars <var_decl 0x7ffff6c026c0 m> supercontext <block 0x7ffff6b88f00> subblocks <block 0x7ffff6bfcd20> chain <block 0x7ffff6bfcd80> abstract_origin <function_decl 0x7ffff7736000 operator+=>> abstract_origin <function_decl 0x7ffff771ad00 __ct >> abstract_origin <function_decl 0x7ffff771ad00 __ct >> abstract_origin <function_decl 0x7ffff771ad00 __ct >> abstract_origin <function_decl 0x7ffff771ad00 __ct >>
        abstract_origin <function_decl 0x7ffff771ae00 __conv_op  type <method_type 0x7ffff771f7e0>
            addressable public static weak function-specific-target function-specific-opt autoinline QI /home/abuild/rpmbuild/BUILD/opencv-3.4.6/modules/ts/include/opencv2/ts/ts_gtest.h:23008:118 align:16 warn_if_not_align:0 context <namespace_decl 0x7ffff7703688 opt_SSE2> abstract_origin <function_decl 0x7ffff771ae00 __conv_op >>> abstract_origin <function_decl 0x7ffff771ae00 __conv_op >>
Comment 1 Martin Liška 2019-07-23 07:38:12 UTC
I was able to debug that with current master of gcc-9-branch.
Comment 2 Richard Biener 2019-07-23 08:53:53 UTC
So the location of the NOTE_INSN_INLINE_ENTRY BLOCK is zero.

# DEBUG INLINE_ENTRY __conv_op 

and the BLOCKs location is streamed as '2', when the location cache is applied
it becomes zero here:

      if (current_file == loc.file && current_line == loc.line
          && current_col == loc.col)
        *loc.loc = current_loc;
      else
        current_loc = *loc.loc = linemap_position_for_column (line_table,
                                                              loc.col);

line changes.  Then linemap_position_for_column returns zero, current_loc
is 1879048191.

(gdb) p set->max_column_hint 
$43 = 0

still we're running into

          /* Otherwise, attempt to start a new line that can hold TO_COLUMN,
             with some space to spare.  This may or may not lead to a new
             linemap being created.  */
          line_map_ordinary *map = LINEMAPS_LAST_ORDINARY_MAP (set);
          r = linemap_line_start (set, SOURCE_LINE (map, r), to_column + 50);

and in linemap_line_start end up with add_map = true because effective_column_bits is zero.

That is, the ultimative issue is that we run out of linemap space
(for no good reason in this case) which leads to some locations becoming
zero which we do not expect.

We can fixup at GIMPLE stmt stream-in time and drop the debug stmts which
make no sense anymore due to this and first and foremost fix the above
bug by not attempting to allocate space for 50 columns if max_column_hint
is zero and the actual column is zero as well.  Hmm, I guess it isn't
a global hint and LTO is really special by dropping column info...  Maybe
we shouldn't call linemap_position_for_column at all...

Anyway.  The following fixes the issue (yes, we do stream inline-entry
markers with NULL block):

Index: gcc/lto-streamer-in.c
===================================================================
--- gcc/lto-streamer-in.c       (revision 273718)
+++ gcc/lto-streamer-in.c       (working copy)
@@ -1140,6 +1140,14 @@ input_function (tree fn_decl, struct dat
                      ? !MAY_HAVE_DEBUG_MARKER_STMTS
                      : !MAY_HAVE_DEBUG_BIND_STMTS))
                remove = true;
+             /* In case the linemap overflows locations can be dropped
+                to zero.  Thus do not keep nonsensical inline entry markers
+                we'd later ICE on.  */
+             tree block;
+             if (gimple_debug_inline_entry_p (stmt)
+                 && (block = gimple_block (stmt))
+                 && !inlined_function_outer_scope_p (block))
+               remove = true;
              if (is_gimple_call (stmt)
                  && gimple_call_internal_p (stmt))
                {

As for the linemap issue we might be able to optimize the + 50 for LTO
somehow either by a new global parameter we set or by looking at past
column uses [of the same file]?
Comment 3 Richard Biener 2019-07-23 10:46:31 UTC
Author: rguenth
Date: Tue Jul 23 10:45:59 2019
New Revision: 273733

URL: https://gcc.gnu.org/viewcvs?rev=273733&root=gcc&view=rev
Log:
2019-07-23  Richard Biener  <rguenther@suse.de>

	PR debug/91231
	* lto-streamer-in.c (input_function): Drop inline-entry markers
	that ended up with an unknown location block.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lto-streamer-in.c
Comment 4 Richard Biener 2019-07-23 11:18:08 UTC
Author: rguenth
Date: Tue Jul 23 11:17:37 2019
New Revision: 273734

URL: https://gcc.gnu.org/viewcvs?rev=273734&root=gcc&view=rev
Log:
2019-07-23  Richard Biener  <rguenther@suse.de>

	PR debug/91231
	* lto-streamer-in.c (input_function): Drop inline-entry markers
	that ended up with an unknown location block.

Modified:
    branches/gcc-9-branch/gcc/ChangeLog
    branches/gcc-9-branch/gcc/lto-streamer-in.c
Comment 5 Richard Biener 2019-07-23 12:14:58 UTC
Author: rguenth
Date: Tue Jul 23 12:14:27 2019
New Revision: 273736

URL: https://gcc.gnu.org/viewcvs?rev=273736&root=gcc&view=rev
Log:
2019-07-23  Richard Biener  <rguenther@suse.de>

	PR debug/91231
	* lto-streamer-in.c (input_function): Drop inline-entry markers
	that ended up with an unknown location block.

Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/lto-streamer-in.c
Comment 6 Richard Biener 2019-07-23 12:15:36 UTC
Fixed.