assertion error in linux-nat.c

Bug #78875 reported by Martin Pool
2
Affects Status Importance Assigned to Milestone
gdb
Fix Released
Medium
gdb (Debian)
Fix Released
Undecided
Unassigned
gdb (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: gdb

I was trying to gather information on a hang bug in xorg, and hit this problem in gdb:

mbp@hope% sudo gdb
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu".

warning: not using untrusted file "/home/mbp/.gdbinit"
(gdb) att 4370
Attaching to process 4370
/build/buildd/gdb-6.6/gdb/linux-nat.c:1026: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n

/build/buildd/gdb-6.6/gdb/linux-nat.c:1026: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n
(gdb)

Revision history for this message
Martin Pool (mbp) wrote :

This is

Version: 6.6-0ubuntu1

from feisty

Revision history for this message
In , Bernie Innocenti (codewiz) wrote :

[Converted from Gnats 2238]

When Xorg hangs inside a signal handler,
gdb is unable to attach to it:

bender:~# gdb /usr/local/fdo/bin/Xorg 29958
GNU gdb Red Hat Linux (6.6-4.fc7rh)
[...]
Attaching to program: /usr/local/fdo/bin/Xorg, process 29958
../../gdb/linux-nat.c:1085: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && (WSTOPSIG (status) == SIGSTOP || WSTOPSIG (status) == 0)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

Maybe Xorg also does something weird with signal masks. This is the stack backtrace I get if I rebuild gdb
without the assertion:

0x0000003d3dad9ca8 in __lll_mutex_lock_wait () from /lib64/libc.so.6
(gdb) bt
#0 0x0000003d3dad9ca8 in __lll_mutex_lock_wait () from /lib64/libc.so.6
#1 0x0000003d3da73382 in _L_lock_14395 () from /lib64/libc.so.6
#2 0x0000003d3da72411 in free () from /lib64/libc.so.6
#3 0x00000000004457aa in CloseDevice ()
#4 0x0000000000445b1a in CloseDownDevices ()
#5 0x000000000057ba67 in AbortServer ()
#6 0x000000000057bffe in FatalError ()
#7 0x0000000000483be7 in xf86SigHandler ()
#8 <signal handler called>
#9 0x0000003d3da6f3f9 in _int_malloc () from /lib64/libc.so.6
#10 0x0000003d3da70b3d in malloc () from /lib64/libc.so.6
#11 0x0000000000576007 in Xalloc ()
#12 0x0000000000548ef2 in XkbCopyKeymap ()
#13 0x000000000045c990 in SwitchCoreKeyboard ()
#14 0x00000000004d8d0f in mieqProcessInputEvents ()
#15 0x00000000004842d1 in ProcessInputEvents ()
#16 0x000000000044c8a8 in Dispatch ()
#17 0x000000000043429a in main ()

Release:
6.4, HEAD

Environment:
x86_64-redhat-linux-gnu

Revision history for this message
In , Daniel Jacobowitz (drow) wrote :

From: Daniel Jacobowitz <email address hidden>
To: <email address hidden>
Cc: <email address hidden>
Subject: Re: gdb/2238: assertion failure in linux_nat_attach() when attaching to a hung Xorg instance
Date: Wed, 7 Mar 2007 11:42:11 -0500

 On Wed, Mar 07, 2007 at 04:30:32PM -0000, <email address hidden> wrote:
 > GNU gdb Red Hat Linux (6.6-4.fc7rh)

 Do you get the same results if you use an FSF GDB? I don't know if
 any of the patches Red Hat applies affect this.

 > [...]
 > Attaching to program: /usr/local/fdo/bin/Xorg, process 29958
 > ../../gdb/linux-nat.c:1085: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && (WSTOPSIG (status) == SIGSTOP || WSTOPSIG (status) == 0)' failed.
 > A problem internal to GDB has been detected,
 > further debugging may prove unreliable.
 >
 > Maybe Xorg also does something weird with signal masks. This is the stack backtrace I get if I rebuild gdb
 > without the assertion:

 Could you check which bit of the assertion failed, and how so?
 Probably the wait status is something unusual.

 --
 Daniel Jacobowitz
 CodeSourcery

Revision history for this message
In , Bernie Innocenti (codewiz) wrote :

From: Bernardo Innocenti <email address hidden>
To: Daniel Jacobowitz <email address hidden>
Cc: <email address hidden>
Subject: Re: gdb/2238: assertion failure in linux_nat_attach() when attaching
 to a hung Xorg instance
Date: Wed, 07 Mar 2007 18:29:21 +0100

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 Daniel Jacobowitz wrote:

 > Do you get the same results if you use an FSF GDB? I don't know if
 > any of the patches Red Hat applies affect this.

 Yes, I've rebuilt from gdb's CVS HEAD, hit the same assertion
 failure, then removed the assertion to see if gdb could run
 anyway (and it did).

 >> Maybe Xorg also does something weird with signal masks. This is the stack backtrace I get if I rebuild gdb
 >> without the assertion:
 >
 > Could you check which bit of the assertion failed, and how so?
 > Probably the wait status is something unusual.

 I can't restart the debug session now because the X server
 is now running fine, but I did some tests and I remember
 these facts:

   pid == GET_PID (inferior_ptid)

 This bit was definitely true

   && WIFSTOPPED (status)

 This was also true

   && (WSTOPSIG (status) == SIGSTOP

 I think this wasn't true, but I don't know what the signal
 number was in the debug session for which I provided the
 stack trace.

 In a different debug session, its value was 29 (SIGIO),
 which the X server actually uses to handle protocol
 requests.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)

 iD8DBQFF7vZxxFEDB3H/S6wRApXGAJoCJGewaZJ9384d5Iv9xW8pJDj6pQCfWynK
 YLg+l7FPpSrD3+3cQNsqZDA=
 =45sh
 -----END PGP SIGNATURE-----

Revision history for this message
In , Greenrd-presidium (greenrd-presidium) wrote :

From: Robin Green <email address hidden>
To: <email address hidden>
Cc: <email address hidden>
Subject: Re: gdb/2238: assertion failure in linux_nat_attach() when attaching
 to a hung Xorg instance
Date: Thu, 26 Apr 2007 10:11:10 -0400 (EDT)

 I have also encountered this bug with gdb 6.6. I have a core dump, and gdb
 tells me the pids match, and the value of status is 7551.

 Daniel Jacobowitz wrote:
 > Could you check which bit of the assertion failed, and how so?
 > Probably the wait status is something unusual.

Revision history for this message
Timo Aaltonen (tjaalton) wrote :

confirming this on gutsy too.

Changed in gdb:
status: New → Confirmed
Changed in gdb:
status: Unknown → New
Revision history for this message
In , Marcus Better (mbetter) wrote :

From: Marcus Better <email address hidden>
To: <email address hidden>
Cc:
Subject: Re: gdb/2238: assertion failure in linux_nat_attach() when attaching to a hung Xorg instance
Date: Mon, 24 Sep 2007 10:00:24 +0200

 I and others have hit this problem with gdb 6.6 on Debian x86_64 and powerpc
 as well when trying to debug X:

 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=422007
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=423775
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=443794

 Marcus

Changed in gdb:
status: New → Confirmed
Revision history for this message
In , Drow-sources (drow-sources) wrote :

The assertion failing in this bug was removed on May 1, 2008. The new code is
more accepting of unusual wait statuses. I believe this is fixed.

2008-05-01 Daniel Jacobowitz <email address hidden>
            Pedro Alves <email address hidden>

        Based on work by Jan Kratochvil <email address hidden> and Jeff
        Johnston <email address hidden>.

        * NEWS: Mention attach to stopped process fix.
        * infcmd.c (detach_command, disconnect_command): Discard the thread
        list.
        * infrun.c (handle_inferior_event): Do not ignore non-SIGSTOP while
        attaching. Use signal_stop_state.
        (signal_stop_state): Check stop_soon.
        * linux-nat.c (kill_lwp): Declare earlier.
        (pid_is_stopped, linux_nat_post_attach_wait): New.
        (lin_lwp_attach_lwp): Use linux_nat_post_attach_wait. Update
        comments.
        (linux_nat_attach): Use linux_nat_post_attach_wait.
        (detach_callback, linux_nat_detach): Improve handling for signalled
        processes.
        (linux_nat_pid_to_str): Always print out the LWP ID if it differs
        from the process ID.
        * Makefile.in (infcmd.o): Update.

Changed in gdb:
status: Unknown → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

upstream claims this is fixed in current trunk (available in karmic)

Changed in gdb (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
In , Tromey-redhat (tromey-redhat) wrote :

*** Bug 9367 has been marked as a duplicate of this bug. ***

Revision history for this message
Artur Rona (ari-tczew) wrote :

 gdb (6.8.50.20090628-1) unstable; urgency=low

   * New snapshot from trunk. The experimental packages used the
     archer-tromey-python branch; the whole branch has not been merged
     to trunk, but significant portions of it have, and will be in GDB 7.
     So this includes some Python scripting support. Other highlights
     since the last experimental package:
     - Reverse debugging commands. With a remote target that supports
       reverse debugging, you can step backwards as easily as forwards.
     - Process record and replay, a native Linux implementation of
       reverse debugging. Only 32-bit IA32 Linux is currently supported.
     - MIPS/Linux hardware watchpoint support.
     - Multi-byte and wide character set support, including wchar_t display.
     - Inlined function support, including in backtrace and step/next/finish.
     - Improved C++ template name parsing.
     - Non-stop debugging (some threads remain running while others
       are stopped in the debugger). Only implemented so far for i386,
       x86-64, and powerpc.
     - A bug fix for discontiguous code, e.g. as found in the Linux kernel
       (Closes: #513816).
     - A build fix that affected SPARC (Closes: #512121).
     - A build fix for casts on hurd-i386 (Closes: #494839).
     - A fix for debugging multi-threaded programs that call exec, including
       Eclipse with the Sun JVM (Closes: #490046).
   * Removed thread-db-multiple-libraries.patch. This let one GDB work with
     both LinuxThreads and NPTL, but no Debian platform has both now.
   * GDB now reads /etc/gdb/gdbinit at startup (Closes: #33187).
   * Ship required libraries (libbfd, libopcodes, and libiberty) in
     /usr/lib/gdb in the libgdb-dev package, in case binutils-dev's versions
     are not close enough (Closes: #509873).
   * Add dev package dependencies to libgdb-dev.

 -- Daniel Jacobowitz <email address hidden> Sun, 05 Jul 2009 16:25:07 -0400

Changed in gdb (Debian):
importance: Unknown → Undecided
status: Confirmed → New
status: New → Fix Released
Changed in gdb:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.