public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
@ 2021-01-19 19:53 dmalcolm at gcc dot gnu.org
  2021-01-19 19:54 ` [Bug debug/98751] " dmalcolm at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-01-19 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98751
           Summary: libgccjit fails in DWARF 5 handling with
                    "`.Ldebug_loc2' is already defined" asm error
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Most of the jit.exp testsuite is failing, where the tests fail on 3rd
in-process iteration, with asm errors of the form:
   symbol `.Ldebug_loc2' is already defined
 test-factorial.c.exe iteration 3 of 5: writing reproducer to
./test-factorial.c.exe.reproducer.c
/tmp/libgccjit-7lPSFo/fake.s: Assembler messages:
/tmp/libgccjit-7lPSFo/fake.s:145: Error: symbol `.Ldebug_loc2' is already
defined
./test-factorial.c.exe: error: error invoking gcc driver
        FAILED: test-factorial.c.exe iteration 3 of 5: verify_code: result is
NULL

Adding this to set_options in jit.dg/harness.h:
  gcc_jit_context_set_bool_option (
    ctxt,
    GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES,
    1);
allows the asm to be inspected after the test runs which has:

1st iteration:
 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc0:
 146   │ .LLST0:

2nd iteration:

 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc1:
 146   │ .LLST0:

3rd iteration:

 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc2:
 146   │ .LLST0:

Note how line 145's number increments each time, and on the 3rd iteration is a
duplicate, leading to failure.

The bogus label is being emitted at:
  31673       ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);

init_sections_and_labels:
  ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
                               generation);

where "generations" is a static local to init_sections_and_labels that
increments, and thus eventually hits the duplicate value.

It looks like generations is meant to be just 0 or 1, but in libgccjit the
compilation code can get repeatedly invoked an arbitrary number of times in
process.  If generations is meant to be just 0 or 1, should this value be reset
to 0 at the end of toplev::main ?  Doing so is likely to fix this bug.

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

* [Bug debug/98751] libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
  2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
@ 2021-01-19 19:54 ` dmalcolm at gcc dot gnu.org
  2021-01-19 20:33 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-01-19 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
s/generations/generation/g

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

* [Bug debug/98751] libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
  2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
  2021-01-19 19:54 ` [Bug debug/98751] " dmalcolm at gcc dot gnu.org
@ 2021-01-19 20:33 ` jakub at gcc dot gnu.org
  2021-01-19 21:11 ` [Bug debug/98751] [11 Regression] " dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-01-19 20:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50006
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50006&action=edit
gcc11-pr98751.patch

Completely untested patch.

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

* [Bug debug/98751] [11 Regression] libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
  2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
  2021-01-19 19:54 ` [Bug debug/98751] " dmalcolm at gcc dot gnu.org
  2021-01-19 20:33 ` jakub at gcc dot gnu.org
@ 2021-01-19 21:11 ` dmalcolm at gcc dot gnu.org
  2021-01-20  0:59 ` cvs-commit at gcc dot gnu.org
  2021-01-20  1:02 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-01-19 21:11 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Priority|P3                          |P1
   Last reconfirmed|                            |2021-01-19
            Summary|libgccjit fails in DWARF 5  |[11 Regression] libgccjit
                   |handling with               |fails in DWARF 5 handling
                   |"`.Ldebug_loc2' is already  |with "`.Ldebug_loc2' is
                   |defined" asm error          |already defined" asm error
           Assignee|unassigned at gcc dot gnu.org      |dmalcolm at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #2)
> Created attachment 50006 [details]
> gcc11-pr98751.patch
> 
> Completely untested patch.

I independently wrote effectively the same patch.  It seems to fix the jit
issues.

I'm running a full test now.

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

* [Bug debug/98751] [11 Regression] libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
  2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-01-19 21:11 ` [Bug debug/98751] [11 Regression] " dmalcolm at gcc dot gnu.org
@ 2021-01-20  0:59 ` cvs-commit at gcc dot gnu.org
  2021-01-20  1:02 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-20  0:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

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

commit r11-6808-gb83604c75fee324cc4767d039178cba2fbbe017e
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Jan 19 19:58:23 2021 -0500

    dwarf2out: reset generation count in toplev::finalize [PR98751]

    PR debug/98751 reports an issue in which most of libgccjit's tests
    fails in DWARF 5 handling with
      `.Ldebug_loc2' is already defined"
    asm errors.

    The bogus label is being emitted at the 3rd in-process iteration, at:
      31673       ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
    which on the initial iteration emits:

     145   â .Ldebug_loc0:

    on the 2nd iteration:
     145   â .Ldebug_loc1:

    and on the 3rd iteration:
     145   â .Ldebug_loc2:

    which is a duplicate of a label emitted earlier:
     138   â     .section    .debug_loclists,"",@progbits
     139   â     .long   .Ldebug_loc3-.Ldebug_loc2
     140   â .Ldebug_loc2:
     141   â     .value  0x5
     142   â     .byte   0x8
     143   â     .byte   0
     144   â     .long   0
     145   â .Ldebug_loc2:

    The issue seems to be that init_sections_and_labels creates the label
      ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
                                   generation);

    where "generation" is a static local to init_sections_and_labels that
    increments, and thus eventually hits the duplicate value.

    It appears that this value is intended to be either 0 or 1, but in
    the libgccjit case the compilation code can be invoked an arbitrary
    number of times in-process, and hence can eventually lead to a
    label name collision.

    This patch adds code to dwarf2out_c_finalize (called by
    toplev::finalize in libgccjit) to reset the generation counts,
    fixing the issue.

    gcc/ChangeLog:
            PR debug/98751
            * dwarf2out.c (output_line_info): Rename static variable
            "generation", moving it out of the function to...
            (output_line_info_generation): New.
            (init_sections_and_labels): Likewise, renaming the variable to...
            (init_sections_and_labels_generation): New.
            (dwarf2out_c_finalize): Reset the new variables.

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

* [Bug debug/98751] [11 Regression] libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error
  2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-01-20  0:59 ` cvs-commit at gcc dot gnu.org
@ 2021-01-20  1:02 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2021-01-20  1:02 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed by the above commit.

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

end of thread, other threads:[~2021-01-20  1:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 19:53 [Bug debug/98751] New: libgccjit fails in DWARF 5 handling with "`.Ldebug_loc2' is already defined" asm error dmalcolm at gcc dot gnu.org
2021-01-19 19:54 ` [Bug debug/98751] " dmalcolm at gcc dot gnu.org
2021-01-19 20:33 ` jakub at gcc dot gnu.org
2021-01-19 21:11 ` [Bug debug/98751] [11 Regression] " dmalcolm at gcc dot gnu.org
2021-01-20  0:59 ` cvs-commit at gcc dot gnu.org
2021-01-20  1:02 ` dmalcolm 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).