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

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).