public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30651] New: GDB crash on _BitInt debuginfo
@ 2023-07-18 17:33 jakub at redhat dot com
  2023-07-18 17:33 ` [Bug gdb/30651] " jakub at redhat dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: jakub at redhat dot com @ 2023-07-18 17:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30651

            Bug ID: 30651
           Summary: GDB crash on _BitInt debuginfo
           Product: gdb
           Version: 12.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: jakub at redhat dot com
  Target Milestone: ---

Created attachment 14984
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14984&action=edit
bitint-39a.s

gdb 12.1 (haven't tried more recent) crashes with
../../gdb/dwarf2/attribute.h:90: internal-error: as_unsigned: Assertion
`form_is_unsigned ()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
when trying to debug following testcase:
int v;

__attribute__((noinline, noclone))
void bar (void)
{
  v++;
}

__attribute__((noinline, noclone))
signed _BitInt (19) t111_1mul (unsigned _BitInt (19) x, signed _BitInt (19) y)
{
  signed _BitInt (19) r;
  if (__builtin_mul_overflow (x, y, &r))
    bar ();
  return r;
}

__attribute__((noinline, noclone))
signed _BitInt (19) t111_2mul (signed _BitInt (19) y)
{
  unsigned _BitInt (19) x = (2);
  signed _BitInt (19) r;
  if (__builtin_mul_overflow (x, y, &r))
    bar ();
  return r;
}

__attribute__((noinline, noclone))
signed _BitInt (19) t111_3mul (signed _BitInt (19) y)
{
  signed _BitInt (19) r;
  if (__builtin_mul_overflow ((unsigned _BitInt (19)) (2), y, &r))
    bar ();
  return r;
}

__attribute__((noinline, noclone))
signed _BitInt (19) t111_4mul (unsigned _BitInt (19) x)
{
  signed _BitInt (19) y = (-262143wb - 1 / 2);
  signed _BitInt (19) r;
  if (__builtin_mul_overflow (x, y, &r))
    bar ();
  return r;
}

__attribute__((noinline, noclone))
signed _BitInt (19) t111_5mul (unsigned _BitInt (19) x)
{
  signed _BitInt (19) r;
  if (__builtin_mul_overflow
      (x, (signed _BitInt (19)) (-262143wb - 1 / 2), &r))
    bar ();
  return r;
}

__attribute__((noinline, noclone))
void t111mul (void)
{
  unsigned _BitInt (19) x = (2);
  signed _BitInt (19) y = (-262143wb - 1 / 2);
  signed _BitInt (19) r1, r2;
  v = 0;
  if (t111_1mul (x, y) != (signed _BitInt (19)) (-262143wb - 1)
      || t111_2mul (y) != (signed _BitInt (19)) (-262143wb - 1)
      || t111_3mul (y) != (signed _BitInt (19)) (-262143wb - 1)
      || t111_4mul (x) != (signed _BitInt (19)) (-262143wb - 1)
      || t111_5mul (x) != (signed _BitInt (19)) (-262143wb - 1))
    __builtin_abort ();
  if (__builtin_mul_overflow (x, y, &r1))
    bar ();
  if (r1 != (signed _BitInt (19)) (-262143wb - 1))
    __builtin_abort ();
  if (__builtin_mul_overflow
      ((unsigned _BitInt (19)) (2),
       (signed _BitInt (19)) (-262143wb - 1 / 2), &r2))
    bar ();
  if (r2 != (signed _BitInt (19)) (-262143wb - 1) || v != 7 * 0)
    __builtin_abort ();
}

int
main ()
{
  t111mul ();
  return 0;
}

with GCC trunk patched with
https://gcc.gnu.org/bugzilla/attachment.cgi?id=55572&action=diff
compiled with -g -std=gnu2x.
The DW_TAG_base_type for _BitInt uses
        .byte   0x4     # uleb128 0x4; (abbrev code)
        .byte   0x24    # uleb128 0x24; (TAG: DW_TAG_base_type)
        .byte   0       # DW_children_no
        .byte   0xb     # uleb128 0xb; (DW_AT_byte_size)
        .byte   0x21    # uleb128 0x21; (DW_FORM_implicit_const)
        .byte   0x4     # sleb128 4
        .byte   0x3e    # uleb128 0x3e; (DW_AT_encoding)
        .byte   0xb     # uleb128 0xb; (DW_FORM_data1)
        .byte   0xd     # uleb128 0xd; (DW_AT_bit_size)
        .byte   0x21    # uleb128 0x21; (DW_FORM_implicit_const)
        .byte   0x13    # sleb128 19
        .byte   0x3     # uleb128 0x3; (DW_AT_name)
        .byte   0xe     # uleb128 0xe; (DW_FORM_strp)
        .byte   0
        .byte   0
but I don't see anything wrong on that, DW_FORM_implicit_const always uses
sleb128
encoding of the constant and all that matters is whether that constant is
signed or unsigned, not that it uses sleb128 encoding.
The crash is after
run
up

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2023-07-21 20:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
2023-07-18 17:33 ` [Bug gdb/30651] " jakub at redhat dot com
2023-07-18 21:35 ` tromey at sourceware dot org
2023-07-20 21:31 ` tromey at sourceware dot org
2023-07-20 21:57 ` jakub at redhat dot com
2023-07-20 22:11 ` tromey at sourceware dot org
2023-07-20 22:12 ` tromey at sourceware dot org
2023-07-21 20:20 ` cvs-commit at gcc dot gnu.org
2023-07-21 20:21 ` tromey at sourceware dot 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).