public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: archer@sourceware.org
Subject: [BUG] gdb: quit hangs after step into signal handler
Date: Mon, 20 Sep 2010 21:20:00 -0000	[thread overview]
Message-ID: <20100920211715.GA10574@redhat.com> (raw)

In short, gdb uses ptrace(PTRACE_KILL) + wait() to detach/kill the tracee.
Well, I think PTRACE_KILL should be avoided but this is offtopic,
ptrace(PTRACE_CONT, SIGKILL) has the same problem if the tracee has
stepped into the signal handler.

	$ gdb /usr/bin/perl
	GNU gdb (GDB) 7.1
	...
	(gdb)
	(gdb) set args -e '$SIG{HUP}=sub{}; kill HUP, $$; 1 while 1'

(this sets a signal handler for SIGHUP, sends SIGHUP to itself, then
 spins forever)

	(gdb) r
	Starting program: /usr/bin/perl -e '$SIG{HUP}=sub{}; kill HUP, $$; 1 while 1'
	[Thread debugging using libthread_db enabled]

	Program received signal SIGHUP, Hangup.
	0x000000375fa32507 in kill () from /lib64/libc.so.6
	(gdb) si
	0x00000037522a2a40 in Perl_csighandler () from /usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi/CORE/libperl.so

(step into handler)

	(gdb) q
	A debugging session is active.

		Inferior 1 [process 9694] will be killed.

	Quit anyway? (y or n) y

(ptrace(PTRACE_KILL) + wait)

Hangs "forever" in wait4().

At first I thought this is another bug in ptrace-utrace (and I even
started doing the patch), but then I recalled that this is what
upstream does, and ptrace-utrace just tries to be compatible.

There is no signal context after step-into-handler, ptrace(PTRACE_KILL)
or ptrace(PTRACE_CONT, SIGKILL) acts like ptrace(CONT, pid, 0,0) and
just resumes the tracee.

Probably gdb should just do kill(tracee, SIGKILL) when it wants
to terminate the tracee.

Oleg.

             reply	other threads:[~2010-09-20 21:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 21:20 Oleg Nesterov [this message]
2010-09-21 23:54 ` Roland McGrath
2011-02-23 20:25   ` [patch] " Jan Kratochvil
2011-02-23 20:27     ` Roland McGrath

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=20100920211715.GA10574@redhat.com \
    --to=oleg@redhat.com \
    --cc=archer@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).