public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "palves at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/14382] gdb hangs after plotting with matplotlib
Date: Tue, 26 May 2015 10:26:00 -0000	[thread overview]
Message-ID: <bug-14382-4717-SpsUno3gz1@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14382-4717@http.sourceware.org/bugzilla/>

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

--- Comment #16 from Pedro Alves <palves at redhat dot com> ---
Created attachment 8333
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8333&action=edit
make linux-nat.c use signalfd

I tried making linux-nat.c use signalfd now.  Unless I missed something, it
doesn't seem to actually work for protecting against a library stealing
SIGCHLDs though, so it ends up useless.  :-/

See the #if 0 in the patch:

~~~
#if 0
      /* Hmm, if we don't do this, then gdb hangs in wait_for_sigchld.
         That seems to mean that if a SIGCHLD signal handler is
         called, then the signalfd file ends up with nothing to read,
         and thus 'select' blocks forever.  Test with:

         "gdb PROGRAM -ex "maint set target-async off" -ex "set debug lin-lwp
1"

         Which renders this approach worthless to protect against a
         library GDB links against from stealing out SIGCHLD
         handler... :-/
      */
~~~~~~~~~~~~~~~~~~

If I leave that on, things work, but if I disable it, I get:

~~~
 $ gdb ~/gdb/tests/threads  -ex "maint set target-async off" -ex "set debug
lin-lwp 1"
 (gdb) start
 (...)
 LLW: exit
 LLR: Preparing to resume process 15243, 0, inferior_ptid process 15243
 LLR: PTRACE_CONT process 15243, 0 (resume event thread)
 linux_nat_wait: [process 15243], []
 LLW: enter
 LNW: waitpid(-1, ...) returned 0, No child processes
 LNW: about to sigsuspend
 sigchld
 ^C^C^C^C^C^C^C^C *gdb hang*
~~~

Adding more logging in wait_for_sigchld, I could observe that
sometimes, the select returns 1, and then the read fails with EAGAIN.
Thinking that perhaps treating that as "got SIGCHLD, but some handler
consumed it" makes a "(gdb) start" sometimes work, but not always...  It
seems that the select only wakes up / returns 1 if the signal arrives
while gdb is already blocked inside select.  If the signal arrives and
is handled before gdb reaches select, then select hangs forever.  This
kind of makes sense if the signalfd's "data" is generated on the fly
from the pending signals, not really queued in the kernel, which it is
probably how this works on the kernel side...

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


  parent reply	other threads:[~2015-05-26 10:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-21 15:28 [Bug python/14382] New: " joeneeman at gmail dot com
2012-07-31 15:54 ` [Bug python/14382] " tromey at redhat dot com
2012-08-07  0:35 ` joeneeman at gmail dot com
2012-08-07  2:15 ` joeneeman at gmail dot com
2012-08-15 21:33 ` tromey at redhat dot com
2012-08-16 14:24 ` tromey at redhat dot com
2012-08-17  0:51 ` joeneeman at gmail dot com
2012-08-22 15:31 ` palves at redhat dot com
2012-08-22 16:58 ` tromey at redhat dot com
2013-03-07  9:16 ` m at bruenink dot de
2013-08-12 19:35 ` aegges at web dot de
2015-05-24 19:34 ` tromey at sourceware dot org
2015-05-25  8:36 ` palves at redhat dot com
2015-05-25  8:39 ` palves at redhat dot com
2015-05-25 20:52 ` tromey at sourceware dot org
2015-05-26  8:29 ` palves at redhat dot com
2015-05-26  8:56 ` palves at redhat dot com
2015-05-26  9:00 ` palves at redhat dot com
2015-05-26 10:26 ` palves at redhat dot com [this message]
2015-05-26 10:30 ` palves at redhat dot com
2015-05-26 10:32 ` palves at redhat dot com
2015-05-27  3:06 ` tromey at sourceware dot org
2015-05-27 16:36 ` xdje42 at gmail dot com
2015-05-27 18:37 ` palves at redhat dot com
2015-05-27 21:19 ` dje at google dot com
2015-05-28 11:45 ` palves at redhat dot com
2023-09-13 14:56 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-14382-4717-SpsUno3gz1@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).