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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
@ 2023-07-18 17:33 ` jakub at redhat dot com
  2023-07-18 21:35 ` tromey at sourceware dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 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

--- Comment #1 from Jakub Jelinek <jakub at redhat dot com> ---
Created attachment 14985
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14985&action=edit
bitint-39a.c

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-07-18 21:35 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I have a fix, just have to write a test case.

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  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
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-07-20 21:31 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
There should probably be a separate bug for implementing
this stuff in gdb's parser / expression evaluator.

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at redhat dot com @ 2023-07-20 21:57 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Jakub Jelinek <jakub at redhat dot com> ---
Yeah.  I've filed https://dwarfstd.org/issues/230529.1.html proposal for
DWARF6, but it hasn't been discussed yet.  And, while GDB can print some
_BitInt values just fine (seems if they are multiple of 64 bits, it gives up on
others.  Right now when debugging stuff I'm just printing the limbs using
x/<N>gx &var when GDB can't handle it.

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
                   ` (3 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-07-20 22:11 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2023-July/201040.html

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
                   ` (4 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-07-20 22:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Jakub Jelinek from comment #4)
> Yeah.  I've filed https://dwarfstd.org/issues/230529.1.html proposal for
> DWARF6, but it hasn't been discussed yet.  And, while GDB can print some
> _BitInt values just fine (seems if they are multiple of 64 bits, it gives up
> on others.  Right now when debugging stuff I'm just printing the limbs using
> x/<N>gx &var when GDB can't handle it.

It looks like there are new suffixes too?  And the semantics of these aren't
identical to existing int types?  And I guess new ABI... probably will end
up wanting several gdb bugs to implement it all.

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-21 20:20 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4d051f3a4e2839225f7de0ea783e2fdca1c7717e

commit 4d051f3a4e2839225f7de0ea783e2fdca1c7717e
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Jul 20 15:48:46 2023 -0600

    Fix crash with DW_FORM_implicit_const

    Jakub pointed out that using DW_FORM_implicit_const with
    DW_AT_bit_size would cause gdb to crash.  This happened because
    DW_FORM_implicit_const is not an "unsigned" form, causing as_unsigned
    to assert.  This patch fixes the problem.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30651
    Approved-By: Andrew Burgess <aburgess@redhat.com>

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

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

* [Bug gdb/30651] GDB crash on _BitInt debuginfo
  2023-07-18 17:33 [Bug gdb/30651] New: GDB crash on _BitInt debuginfo jakub at redhat dot com
                   ` (6 preceding siblings ...)
  2023-07-21 20:20 ` cvs-commit at gcc dot gnu.org
@ 2023-07-21 20:21 ` tromey at sourceware dot org
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-07-21 20:21 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.1

--- Comment #8 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

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