public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug server/29221] New: tdesc_get_features_xml: Assertion `tdesc->xmltarget != NULL || (!tdesc->features.empty () && tdesc->arch != NULL)' failed unless all-stop `?` is sent before reading target.xml
@ 2022-06-02  8:15 mgorny at gentoo dot org
  0 siblings, 0 replies; only message in thread
From: mgorny at gentoo dot org @ 2022-06-02  8:15 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29221
           Summary: tdesc_get_features_xml: Assertion `tdesc->xmltarget !=
                    NULL || (!tdesc->features.empty () && tdesc->arch !=
                    NULL)' failed unless all-stop `?` is sent before
                    reading target.xml
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: server
          Assignee: unassigned at sourceware dot org
          Reporter: mgorny at gentoo dot org
  Target Milestone: ---

While working on non-stop support in LLDB and testing it against vanilla
gdbserver, I've hit the following assertion:

  tdesc.cc:195: A problem internal to GDBserver has been detected.
  tdesc_get_features_xml: Assertion `tdesc->xmltarget != NULL ||
(!tdesc->features.empty () && tdesc->arch != NULL)' failed.

After some debugging, I've discovered that it is happening because my code
sends the `QNonStop` packet prior to the `?` packet.  If I reversed the order,
gdbserver did not crash.

I've been able to come up with the following "absolutely minimal" reproducer
(piped to gdbserver via nc(1)):

  $QStartNoAckMode#b0
 
$qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+#2e
  $qXfer:features:read:target.xml:0,47fe#81

If I issue a `?` request prior to `qXfer`, gdbserver works correctly:

  $QStartNoAckMode#b0
 
$qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+#2e
  $?#3f
  $qXfer:features:read:target.xml:0,47fe#81

However, if the `?` request is issued in non-stop mode, gdbserver hits the
assertion:

  $QStartNoAckMode#b0
 
$qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+#2e
  $QNonStop:1#8d
  $?#3f
  $vStopped#55
  $qXfer:features:read:target.xml:0,47fe#81

Therefore, my conclusion is that the crash happens unless `?` packet is sent in
all-stop mode prior to `qXfer`.

I've been able to reproduce with 12.1 release and git
a115b2793459e25d8fa5be3dc1c69dcab0a32e53.

To test this, I've used a minimal program:

  int main() { return 0; }

compiled with `gcc -O0 -g`.

gdbserver started as:

  gdbserver --remote-debug 127.0.0.1:1234 a.out

reproducers use via:

  cat ... | nc 127.0.0.1 1234


$ gdbserver --version
GNU gdbserver (Gentoo 9999 vanilla) 13.0.50.20220602-git
Copyright (C) 2022 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-pc-linux-gnu"

$ uname -a
Linux pomiot 5.17.12-gentoo-dist #1 SMP PREEMPT Mon May 30 15:57:46 -00 2022
x86_64 AMD Ryzen 5 3600 6-Core Processor AuthenticAMD GNU/Linux

$ gdb --configuration
This GDB was configured as follows:
   configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib64/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --without-babeltrace
             --without-intel-pt
             --with-mpfr
             --without-xxhash
             --with-python=/usr (relocatable)
             --with-python-libdir=/usr/lib (relocatable)
             --without-debuginfod
             --without-guile
             --disable-source-highlight
             --enable-threading
             --with-separate-debug-dir=/usr/lib/debug (relocatable)

$ gcc --version
gcc (Gentoo 12.1.1_p20220528 p6) 12.1.1 20220528
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-02  8:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  8:15 [Bug server/29221] New: tdesc_get_features_xml: Assertion `tdesc->xmltarget != NULL || (!tdesc->features.empty () && tdesc->arch != NULL)' failed unless all-stop `?` is sent before reading target.xml mgorny at gentoo 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).