This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug record/22368] New: Assertion failure during recorded execution


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

            Bug ID: 22368
           Summary: Assertion failure during recorded execution
           Product: gdb
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: record
          Assignee: unassigned at sourceware dot org
          Reporter: astian at elude dot in
  Target Milestone: ---

I ran into the following 2 assertion failures when trying to record execution
of a function:

  1. /build/gdb-uGdIdO/gdb-7.12/gdb/record-full.c:1066: internal-error: ptid_t
record_full_wait_1(target_ops*, ptid_t, target_waitstatus*, int): Assertion
`(options & TARGET_WNOHANG) != 0' failed.

  2. /build/gdb-uGdIdO/gdb-7.12/gdb/nat/x86-linux-dregs.c:146: internal-error:
void x86_linux_update_debug_registers(lwp_info*): Assertion `lwp_is_stopped
(lwp)' failed.

It happened for the first time while trying to record execution of a keyboard
event handler for a GTK+ widget provided by the `spice-gtk` library and used
in the SPICE client `remote-viewer`, part of the `virt-viewer` package.

Initially I thought it had something to do with the peculiar situation I was
trying to debug: with the keyboard partially "stuck" due to (methinks) being
in the middle of an X server "grab".  However, after some experimentation, I
rather think that some threading shenanigans are at play: the same errors
occur when attempting to record other, more typical, functions in the same
program.

I also confirmed that the recording steps I'm trying to carry out do work when
applied to other functions and other programs.

STR:

  1. On a Debian unstable system (with a configured debug-symbols repository):

       # apt install gdb virt-viewer virt-viewer-dbgsym
libspice-client-gtk-3.0-5-dbgsym

     Which should give you the following packages (among others):

       Package                       Version
       -------------------------------------------------------------
       gdb                           7.12-6+b1 (7.12.0.20161007-git)
       virt-viewer                   6.0-2
       libspice-client-gtk-3.0-5     0.34-1.1

  2. Set up some SPICE server.  In my case I have a Xen VM for which QEMU
     serves the desktop via a SPICE server.

  3. Run:

      $ gdb -x rv.gdb

     Where "rv.gdb" contains (change the address of the spice server as
needed):

       # Avoid problems with GDB's "record" and call trampolines which
       # usually manifests as:
       #   Process record does not support instruction 0xc5 at address
0x7ffff7be0990.
       #   Process record: failed to record execution log.
       set environment LD_BIND_NOW 1

       # Avoid interruptions.
       set pagination off
       set record full stop-at-limit off

       file /usr/bin/remote-viewer

       start spice://localhost:12333

       # This was the original reproducer for this bug.  To trigger this
       # breakpoint, bring remote-viewer's window into focus and press (or
       # release) some key.
       #
       # Function "key_event" (in library "spice-gtk") is a GTK+ widget
       # keyboard event handler.
       #break key_event
       #commands
       #echo Recording function...\n
       #record
       #finish
       #end

       break virt_viewer_app_on_application_startup
       # Uncomment this "next" and you get a different error, see below.
       #next
       continue
       next

Result:  GDB stops because of an assertion failure.  The failed assertion is
one of the two listed above.  It varies which one but the 1st is most common.

I also reproduced the bug using my own from-source debug builds of GDB (from
8.0.50-20171029 tarball), virt-viewer (from Debian source package) and
spice-gtk (from Debian source package).

Example transcript showing the first assertion failure:

  $ gdb -x rv.gdb
  GNU gdb (Debian 7.12-6+b1) 7.12.0.20161007-git
  Copyright (C) 2016 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
  and "show warranty" for details.
  This GDB was configured as "x86_64-linux-gnu".
  Type "show configuration" for configuration details.
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>.
  Find the GDB manual and other documentation resources online at:
  <http://www.gnu.org/software/gdb/documentation/>.
  For help, type "help".
  Type "apropos word" to search for commands related to "word".
  Temporary breakpoint 1 at 0x129b0: file remote-viewer-main.c, line 35.
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

  Temporary breakpoint 1, main (argc=2, argv=0x7fffffffe278) at
remote-viewer-main.c:35
  35    remote-viewer-main.c: No such file or directory.
  Breakpoint 2 at 0x5555555709a0: file virt-viewer-app.c, line 1811.
  [New Thread 0x7fffe18cf700 (LWP 15211)]
  [New Thread 0x7fffe10ce700 (LWP 15212)]

  Thread 1 "remote-viewer" hit Breakpoint 2,
virt_viewer_app_on_application_startup (app=0x5555557f2300 [RemoteViewer]) at
virt-viewer-app.c:1811
  1811  virt-viewer-app.c: No such file or directory.
  /build/gdb-uGdIdO/gdb-7.12/gdb/record-full.c:1066: internal-error: ptid_t
record_full_wait_1(target_ops*, ptid_t, target_waitstatus*, int): Assertion
`(options & TARGET_WNOHANG) != 0' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) [answered Y; input not from terminal]

  This is a bug, please report it.  For instructions, see:
  <http://www.gnu.org/software/gdb/bugs/>.

  /build/gdb-uGdIdO/gdb-7.12/gdb/record-full.c:1066: internal-error: ptid_t
record_full_wait_1(target_ops*, ptid_t, target_waitstatus*, int): Assertion
`(options & TARGET_WNOHANG) != 0' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Create a core file of GDB? (y or n) [answered Y; input not from terminal]
  Aborted (core dumped)

(I can provide the core dump if required.)

In the script, if instead of:

  break ...
  continue
  next

...one does:

  break ...
  next
  continue
  next

...instead of the assertion failure we get:

  [...]
  Temporary breakpoint 1, main (argc=2, argv=0x7fffffffe278) at
remote-viewer-main.c:35
  35    remote-viewer-main.c: No such file or directory.
  Breakpoint 2 at 0x5555555709a0: file virt-viewer-app.c, line 1811.
  [New Thread 0x7fffe18cf700 (LWP 15504)]
  [New Thread 0x7fffe10ce700 (LWP 15505)]

  Thread 1 "remote-viewer" hit Breakpoint 2,
virt_viewer_app_on_application_startup (app=0x5555557f2300 [RemoteViewer]) at
virt-viewer-app.c:1811
  1811  virt-viewer-app.c: No such file or directory.
  1812  in virt-viewer-app.c
  rv.gdb:16: Error in sourced command file:
  Couldn't get registers: No such process.
  (gdb)

The inferior seems to be in a very bad state now:

  (gdb) next
  Cannot execute this command while the selected thread is running.

Also note that the active thread was changed from 1 to 3:

  (gdb) info thread
    Id   Target Id         Frame
    1    Thread 0x7ffff7f8c540 (LWP 15500) "remote-viewer" (running)
    2    Thread 0x7fffe18cf700 (LWP 15504) "gmain" (running)
  * 3    Thread 0x7fffe10ce700 (LWP 15505) "gdbus" (running)

Changing it back to 1 does not help.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]