public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038
@ 2022-09-27 16:27 gscfq@t-online.de
  2022-09-27 16:31 ` [Bug debug/107058] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2022-09-27 16:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

            Bug ID: 107058
           Summary: [11/12/13 Regression] ICE in
                    dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started with g++-11 between 20201108 and 20201115,
using file c-c++-common/pr50459.c :


$ gcc-13-20220925 -c pr50459.c -flto -g -fdebug-types-section
$
$ g++-13-20220925 -c pr50459.c -flto -g -fdebug-types-section
during IPA pass: modref
pr50459.c:13:37: internal compiler error: in dwarf2out_die_ref_for_decl, at
dwarf2out.cc:6038
   13 | int __attribute__((aligned (A))) foo;
      |                                     ^
0xd29259 dwarf2out_die_ref_for_decl
        ../../gcc/dwarf2out.cc:6037
0x1017061 lto_write_tree_1
        ../../gcc/lto-streamer-out.cc:535
0x1017180 lto_write_tree
        ../../gcc/lto-streamer-out.cc:561
0x1017180 lto_output_tree_1
        ../../gcc/lto-streamer-out.cc:592
0x101f425 DFS::DFS(output_block*, tree_node*, bool, bool, bool)
        ../../gcc/lto-streamer-out.cc:892
0x1020bdb lto_output_tree(output_block*, tree_node*, bool, bool)
        ../../gcc/lto-streamer-out.cc:1859
0x1016a02 write_global_stream
        ../../gcc/lto-streamer-out.cc:2853
0x1023cf1 lto_output_decl_state_streams(output_block*, lto_out_decl_state*)
        ../../gcc/lto-streamer-out.cc:2900
0x1023cf1 produce_asm_for_decls()
        ../../gcc/lto-streamer-out.cc:3294
0x10c30bf write_lto
        ../../gcc/passes.cc:2771
0x10c716e ipa_write_summaries_1
        ../../gcc/passes.cc:2832
0x10c716e ipa_write_summaries()
        ../../gcc/passes.cc:2888
0xca8783 ipa_passes
        ../../gcc/cgraphunit.cc:2208
0xca8783 symbol_table::compile()
        ../../gcc/cgraphunit.cc:2281
0xcac42f symbol_table::compile()
        ../../gcc/cgraphunit.cc:2532
0xcac42f symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.cc:2529

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug debug/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
@ 2022-09-27 16:31 ` pinskia at gcc dot gnu.org
  2022-09-27 16:42 ` [Bug ipa/107058] " mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-27 16:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.4
           Keywords|                            |lto
          Component|c++                         |debug

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ipa/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
  2022-09-27 16:31 ` [Bug debug/107058] " pinskia at gcc dot gnu.org
@ 2022-09-27 16:42 ` mpolacek at gcc dot gnu.org
  2022-09-27 17:24 ` [Bug ipa/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380 marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-09-27 16:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-09-27
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug ipa/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
  2022-09-27 16:31 ` [Bug debug/107058] " pinskia at gcc dot gnu.org
  2022-09-27 16:42 ` [Bug ipa/107058] " mpolacek at gcc dot gnu.org
@ 2022-09-27 17:24 ` marxin at gcc dot gnu.org
  2022-09-29  8:05 ` [Bug debug/107058] " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-27 17:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13 Regression] ICE   |[11/12/13 Regression] ICE
                   |in                          |in
                   |dwarf2out_die_ref_for_decl, |dwarf2out_die_ref_for_decl,
                   |at dwarf2out.cc:6038        |at dwarf2out.cc:6038 since
                   |                            |r11-5003-gd50310408f54e380
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-5003-gd50310408f54e380.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug debug/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2022-09-27 17:24 ` [Bug ipa/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380 marxin at gcc dot gnu.org
@ 2022-09-29  8:05 ` rguenth at gcc dot gnu.org
  2023-05-29 10:07 ` [Bug debug/107058] [11/12/13/14 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-29  8:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|ipa                         |debug
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
#1  0x0000000001223942 in dwarf2out_die_ref_for_decl (decl=
    <const_decl 0x7ffff669a000 A>, sym=0x7fffffffd170, off=0x7fffffffd168)
    at /home/rguenther/src/trunk/gcc/dwarf2out.cc:6037
6037      gcc_assert (die->die_tag == DW_TAG_compile_unit
(gdb) l
6032      *off = die->die_offset;
6033      while (die->die_parent)
6034        die = die->die_parent;
6035      /* For the containing CU DIE we compute a die_symbol in
6036         compute_comp_unit_symbol.  */
6037      gcc_assert (die->die_tag == DW_TAG_compile_unit
6038                  && die->die_id.die_symbol != NULL);
6039      *sym = die->die_id.die_symbol;
6040      return true;
6041    }
(gdb) p die->die_tag
$1 = DW_TAG_type_unit
(gdb) p die->die_id.die_symbol
$2 = 0x0

I think -fdebug-types-section isn't handled by early LTO debug I also think
we have a duplicate about this.

It might also be time to get rid of -fdebug-tyes-section?  Nobody uses it.

But I'm also not sure why the DIE for a CONST_DECL is inside a type unit?

(gdb) p debug_tree (expr)
 <const_decl 0x7ffff669a000 A
    type <enumeral_type 0x7ffff6685738 ._anon_0
        type <integer_type 0x7ffff66857e0 unsigned int public unsigned SI
            size <integer_cst 0x7ffff653d1c8 constant 32>
            unit-size <integer_cst 0x7ffff653d1e0 constant 4>
            align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff66857e0 precision:8 min <integer_cst 0x7ffff6693a68 0> max <integer_cst
0x7ffff6661ea0 255>>
        asm_written unsigned type_6 SI size <integer_cst 0x7ffff653d1c8 32>
unit-size <integer_cst 0x7ffff653d1e0 4>
        align:32 warn_if_not_align:0 symtab:-162242480 alias-set -1
canonical-type 0x7ffff6685738 precision:32 min <integer_cst 0x7ffff653d1f8 0>
max <integer_cst 0x7ffff653d1b0 4294967295> context <translation_unit_decl
0x7ffff6525168 pr50459.c>>
    readonly constant used VOID pr50459.c:6:8
    align:1 warn_if_not_align:0 context <translation_unit_decl 0x7ffff6525168
pr50459.c> initial <integer_cst 0x7ffff6693ab0 128> chain <type_decl
0x7ffff654abe0 ._anon_0>>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug debug/107058] [11/12/13/14 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-09-29  8:05 ` [Bug debug/107058] " rguenth at gcc dot gnu.org
@ 2023-05-29 10:07 ` jakub at gcc dot gnu.org
  2024-01-23  8:52 ` [Bug c++/107058] " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/107058] [11/12/13/14 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2023-05-29 10:07 ` [Bug debug/107058] [11/12/13/14 " jakub at gcc dot gnu.org
@ 2024-01-23  8:52 ` rguenth at gcc dot gnu.org
  2024-01-23 10:15 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-23  8:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|debug                       |c++

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The particular reason we even stream the CONST_DECL is that it appears in

int __attribute__((aligned (A))) foo;

via the attribute list:

 <var_decl 0x7ffff6a1ae10 foo
    type <integer_type 0x7ffff6a305e8 int asm_written public type_6 SI
        size <integer_cst 0x7ffff6a2a408 constant 32>
        unit-size <integer_cst 0x7ffff6a2a420 constant 4>
        align:32 warn_if_not_align:0 symtab:-157035984 alias-set 2
canonical-type 0x7ffff6a305e8 precision:32 min <integer_cst 0x7ffff6a2a3c0
-2147483648> max <integer_cst 0x7ffff6a2a3d8 2147483647>
        pointer_to_this <pointer_type 0x7ffff6a37b28>>
    addressable public static SI pr50459.c:13:34 size <integer_cst
0x7ffff6a2a408 32> unit-size <integer_cst 0x7ffff6a2a420 4>
    user align:1024 warn_if_not_align:0 context <translation_unit_decl
0x7ffff6a19168 pr50459.c>
    attributes <tree_list 0x7ffff6bc6000
        purpose <identifier_node 0x7ffff6a2c980 aligned>
        value <tree_list 0x7ffff6bb9be0 value <const_decl 0x7ffff6bc5000 A>>>
chain <var_decl 0x7ffff6a1ad80 a>>

where we "failed" to replace the CONST_DECL with its value.  When handling
the attribute we're doing

      align_expr = TREE_VALUE (args);
      if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE
          && TREE_CODE (align_expr) != FUNCTION_DECL)
        align_expr = default_conversion (align_expr);

and that resolves it to an INTEGER_CST for further processing.

I'll note that streaming out debug references from certain contexts like
attribute arguments is also unnecessary but it's difficult to selectively
disable it.

IMO the correct thing to do is for the C++ frontend to, like the C frontend,
resolve the enumerators before calling common_handle_aligned_attribute.

It's also possible to more gracefully handle the assert it's still a bug.
I'm going to handle it gracefully when not checking.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/107058] [11/12/13/14 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2024-01-23  8:52 ` [Bug c++/107058] " rguenth at gcc dot gnu.org
@ 2024-01-23 10:15 ` cvs-commit at gcc dot gnu.org
  2024-01-23 10:16 ` rguenth at gcc dot gnu.org
  2024-03-22 14:02 ` law at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-23 10:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:e2f3057fc911f9f55986b3de237b0155c0e09fe8

commit r14-8351-ge2f3057fc911f9f55986b3de237b0155c0e09fe8
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jan 23 09:51:00 2024 +0100

    debug/107058 - gracefully handle unexpected DIE contexts

    While the bug is persisting that LTO streaming picks up a CONST_DECL
    from an attribute argument on a VAR_DECL which with -fdebug-type-section
    refers to a DIE in a type unit we can handle this gracefully, at least
    with -fno-checking.  Do so.  The C++ frontend nevetheless should resolve
    the CONST_DECL attribute argument to a constant.

            PR debug/107058
            * dwarf2out.cc (dwarf2out_die_ref_for_decl): Gracefully
            handle unexpected but bogus DIE contexts when not checking
            enabled.

            * c-c++-common/pr107058.c: New testcase.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/107058] [11/12/13/14 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2024-01-23 10:15 ` cvs-commit at gcc dot gnu.org
@ 2024-01-23 10:16 ` rguenth at gcc dot gnu.org
  2024-03-22 14:02 ` law at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-23 10:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-checking

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Improved to ice-checking.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/107058] [11/12/13/14 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380
  2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2024-01-23 10:16 ` rguenth at gcc dot gnu.org
@ 2024-03-22 14:02 ` law at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-22 14:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107058

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-03-22 14:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 16:27 [Bug c++/107058] New: [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 gscfq@t-online.de
2022-09-27 16:31 ` [Bug debug/107058] " pinskia at gcc dot gnu.org
2022-09-27 16:42 ` [Bug ipa/107058] " mpolacek at gcc dot gnu.org
2022-09-27 17:24 ` [Bug ipa/107058] [11/12/13 Regression] ICE in dwarf2out_die_ref_for_decl, at dwarf2out.cc:6038 since r11-5003-gd50310408f54e380 marxin at gcc dot gnu.org
2022-09-29  8:05 ` [Bug debug/107058] " rguenth at gcc dot gnu.org
2023-05-29 10:07 ` [Bug debug/107058] [11/12/13/14 " jakub at gcc dot gnu.org
2024-01-23  8:52 ` [Bug c++/107058] " rguenth at gcc dot gnu.org
2024-01-23 10:15 ` cvs-commit at gcc dot gnu.org
2024-01-23 10:16 ` rguenth at gcc dot gnu.org
2024-03-22 14:02 ` law at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).