public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30455] New: Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed.
@ 2023-05-16 23:51 hi-angel at yandex dot ru
  2023-05-17  0:41 ` [Bug record/30455] " tromey at sourceware dot org
  2023-05-18 14:04 ` tromey at sourceware dot org
  0 siblings, 2 replies; 3+ messages in thread
From: hi-angel at yandex dot ru @ 2023-05-16 23:51 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30455
           Summary: Debuggee with sanitizer causes: Assertion `regnum <
                    gdbarch_num_regs (arch ())' failed.
           Product: gdb
           Version: 13.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: hi-angel at yandex dot ru
  Target Milestone: ---

This is a bug in `record` gdb function.

Note: `record` doesn't work as is on modern CPUs (because they usually have AVX
which is used for example by glibc), but at least in my environment the
workaround is using 32bit debugee (i.e. -m32 in the steps-to-reproduce below).

# Steps to reproduce

     λ cat test.c
    int main(){}
     λ gcc test.c -o a -fsanitize=address -m32
     λ gdb ./a
    Reading symbols from ./a...
    (No debugging symbols found in ./a)
    gdb λ br main
    Breakpoint 1 at 0x11a0
    gdb λ r
    Starting program: /tmp/a
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib/libthread_db.so.1".

    Breakpoint 1, 0x565561a0 in main ()
    gdb λ record
    gdb λ c
    Continuing.
    ../../gdb/regcache.c:324: internal-error: assert_regnum: Assertion `regnum
< gdbarch_num_regs (arch ())' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    ----- Backtrace -----
    0x55618b5d2cfb ???
    0x55618b982cf4 ???
    0x55618ba664d3 ???
    0x55618b887113 ???
    0x55618b887466 ???
    0x55618b8876d1 ???
    0x55618b87f415 ???
    0x55618b767d2a ???
    0x55618b87f6d2 ???
    0x55618b89133a ???
    0x55618b929bbb ???
    0x55618b794d77 ???
    0x55618b795864 ???
    0x55618ba66d5d ???
    0x55618bab84c6 ???
    0x55618b7e34a4 ???
    0x55618b53e664 ???
    0x7fd649a3984f ???
    0x7fd649a39909 ???
    0x55618b545ac4 ???
    0xffffffffffffffff ???
    ---------------------
    ../../gdb/regcache.c:324: internal-error: assert_regnum: Assertion `regnum
< gdbarch_num_regs (arch ())' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

## Expected

No assertion is triggered

## Actual

It fails with assertion

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

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

* [Bug record/30455] Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed.
  2023-05-16 23:51 [Bug gdb/30455] New: Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed hi-angel at yandex dot ru
@ 2023-05-17  0:41 ` tromey at sourceware dot org
  2023-05-18 14:04 ` tromey at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2023-05-17  0:41 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org
          Component|gdb                         |record

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

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

* [Bug record/30455] Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed.
  2023-05-16 23:51 [Bug gdb/30455] New: Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed hi-angel at yandex dot ru
  2023-05-17  0:41 ` [Bug record/30455] " tromey at sourceware dot org
@ 2023-05-18 14:04 ` tromey at sourceware dot org
  1 sibling, 0 replies; 3+ messages in thread
From: tromey at sourceware dot org @ 2023-05-18 14:04 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-05-18
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
Here:

          record_full_arch_list_add_reg (ir.regcache,
                                         I387_MM0_REGNUM (tdep) + ir.reg);
          break;

it's recording register 97.

But:

325         gdb_assert (regnum < gdbarch_num_regs (arch ()));
(top) p gdbarch_num_regs(arch())
$10 = 73


So it's some confusion either in the regcache code or in i386-tdep.c.

Here's the relevant parts of the stack trace:

#9  0x000000000103df82 in internal_error_loc (file=<optimized out>, 
    line=<optimized out>, fmt=<optimized out>)
    at ../../binutils-gdb/gdbsupport/errors.cc:58
#10 0x00000000008b5ace in reg_buffer::assert_regnum (this=0x301fcd0, regnum=97)
    at ../../binutils-gdb/gdb/regcache.c:325
#11 0x00000000008b662f in regcache::raw_update (this=0x301fcd0, regnum=97)
--Type <RET> for more, q to quit, c to continue without paging--c
    at ../../binutils-gdb/gdb/regcache.c:590
#12 0x00000000008b6751 in readable_regcache::raw_read (this=0x301fcd0,
regnum=97, buf=0x319eef0 "") at ../../binutils-gdb/gdb/regcache.c:616
#13 0x00000000008aae50 in record_full_arch_list_add_reg (regcache=0x301fcd0,
regnum=97) at ../../binutils-gdb/gdb/record-full.c:623
#14 0x00000000006d76b3 in i386_process_record (gdbarch=0x262adc0,
regcache=<optimized out>, input_addr=<optimized out>) at
../../binutils-gdb/gdb/i386-tdep.c:8065
#15 0x00000000008ab0f9 in record_full_message (regcache=0x301fcd0,
signal=GDB_SIGNAL_0) at ../../binutils-gdb/gdb/record-full.c:751
#16 0x00000000008ab212 in record_full_message_wrapper_safe (regcache=0x301fcd0,
signal=GDB_SIGNAL_0) at ../../binutils-gdb/gdb/record-full.c:786
#17 0x00000000008ac2a3 in record_full_wait_1 (ops=0x2057bd0 <record_full_ops>,
ptid=..., status=0x7fffffffe138, options=...) at
../../binutils-gdb/gdb/record-full.c:1240
#18 0x00000000008ac9d6 in record_full_base_target::wait (this=0x2057bd0
<record_full_ops>, ptid=..., status=0x7fffffffe138, options=...) at
../../binutils-gdb/gdb/record-full.c:1467
#19 0x0000000000a77ac2 in target_wait (ptid=..., status=0x7fffffffe138,
options=...) at ../../binutils-gdb/gdb/target.c:2586
#20 0x0000000000701cba in do_target_wait_1 (inf=<optimized out>, ptid=...,
status=0x7fffffffe138, options=...) at ../../binutils-gdb/gdb/infrun.c:3864

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

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

end of thread, other threads:[~2023-05-18 14:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 23:51 [Bug gdb/30455] New: Debuggee with sanitizer causes: Assertion `regnum < gdbarch_num_regs (arch ())' failed hi-angel at yandex dot ru
2023-05-17  0:41 ` [Bug record/30455] " tromey at sourceware dot org
2023-05-18 14:04 ` 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).