Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Fix Linux attach to signalled/stopped processes
Date: Wed, 27 Jun 2007 18:30:00 -0000	[thread overview]
Message-ID: <200706271601.l5RG1KoT030784@brahms.sibelius.xs4all.nl> (raw)
In-Reply-To: <20070627065203.GA9427@host0.dyn.jankratochvil.net> (message from 	Jan Kratochvil on Wed, 27 Jun 2007 08:52:03 +0200)

> Date: Wed, 27 Jun 2007 08:52:03 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> 
> On Wed, 27 Jun 2007 00:54:54 +0200, Mark Kettenis wrote:
> ...
> > This is what I get on OpenBSD:
> > 
> > $ ./ptrace-test                                                          
> > .assertion "!WIFSIGNALED (status)" failed: file "ptrace-test.c", line 122, function "main"
> > Abort trap (core dumped) 
> > 
> > This is sort of odd,
> 
> Thanks for the test - it is now confirmed the code is not crossplatform and
> different hacks may be needed on different ptrace(2)-using OSes.
> OK, going to move it to linux-nat.c.
> 
> > but then your test program has a serious problem.
> > It doesn't wait(2) after ptrace(PT_ATTACH, ...).  That's asking for trouble.
> 
> It does wait(2) right after a preventive `PT_CONT (SIGSTOP)' as otherwise
> wait(2) would hang if the original process was already stopped ...

That's a kernel bug in my book; wait(2) should always report a SIGSTOP
after a PT_ATTACH as soon as the traced process has been stopped.  If
the process was already stopped, wait(2) should simply report that
SIGSTOP immediately.

> > > How does currently GDB behave there while attaching to a SIGSTOPped process?
> > 
> > I don't think it matters whether the process is stopped or not.
> 
> ... the same way the current GDB hangs.  SIGSTOP is already delivered before
> and the new SIGSTOP from PTRACE_ATTACH does not stack as SIGSTOP is already
> active.  If the original SIGSTOP was already wait(2)ed by the pre-ptrace(2)
> parent the new ptrace(2)-parent (the debugger) will not get the new SIGSTOP
> caught and thus wait(2) hangs for it.
> [ Info originally from Roland McGrath. ]

So it seems that Linux completely ignores SIGSTOP if a process is
already stopped.  That's the right thing to do for "normal" processes,
but not ok for traced processes.  Looks like fixing that would solve a
lot of problems.  Wouldn't surprise me if that would also make lots of
the workarounds we put in for debugging multi-threaded programs
unnecessary.

Mark


  reply	other threads:[~2007-06-27 16:01 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-06 14:34 Jan Kratochvil
2007-06-11 13:44 ` Jan Kratochvil
2007-06-15 18:02 ` Mark Kettenis
2007-06-26 22:40   ` Jan Kratochvil
2007-06-27  0:13     ` Mark Kettenis
2007-06-27 11:59       ` Jan Kratochvil
2007-06-27 18:30         ` Mark Kettenis [this message]
2007-06-30 11:45         ` Jan Kratochvil
2007-06-30 11:57           ` Eli Zaretskii
2007-06-30 17:15             ` Jan Kratochvil
2007-06-30 18:52               ` Eli Zaretskii
     [not found]               ` <200706301852.l5UIq8ek010536@brahms.sibelius.xs4all.nl>
2007-07-01  3:17                 ` Eli Zaretskii
2007-07-01  9:34                   ` Mark Kettenis
2007-07-01 10:03                     ` Jan Kratochvil
2008-03-31 22:07 Doug Evans
2008-04-02  0:01 ` Jan Kratochvil
2008-04-02  0:07   ` Roland McGrath
2008-04-10 15:30     ` Daniel Jacobowitz
2008-04-10 15:37       ` Jan Kratochvil
2008-04-10 15:49         ` Daniel Jacobowitz
2008-04-10 16:00           ` Jan Kratochvil
2008-04-10 19:59             ` Daniel Jacobowitz
2008-04-10 15:39   ` Daniel Jacobowitz
2008-04-10 16:00     ` Jan Kratochvil
2008-04-10 19:48       ` Daniel Jacobowitz
2008-04-11  8:46       ` Roland McGrath
2008-04-11 17:46         ` Jan Kratochvil
2008-04-11 19:01           ` Daniel Jacobowitz
2008-04-12  7:58           ` Roland McGrath
2008-04-14 15:09             ` Daniel Jacobowitz
2008-04-14 15:31               ` Daniel Jacobowitz
2008-04-15 22:14                 ` Jan Kratochvil
2008-05-01 18:50                   ` Daniel Jacobowitz
2008-07-05  8:48                     ` Jan Kratochvil
2008-07-05 13:48                       ` Daniel Jacobowitz
2008-09-24 12:46                 ` Andreas Schwab
2008-09-26  3:52                   ` Jan Kratochvil
2008-09-26 13:00                     ` Daniel Jacobowitz
2008-09-28 11:43                       ` Jan Kratochvil
2008-09-28 14:58                         ` Daniel Jacobowitz
2008-04-15  8:14               ` Roland McGrath
2008-04-15 13:02                 ` Daniel Jacobowitz
2008-04-16  7:01                   ` Roland McGrath
2008-04-11 22:20         ` Daniel Jacobowitz
2008-04-11 22:21           ` Pedro Alves
2008-04-11 22:25             ` Daniel Jacobowitz
2008-04-12  0:02               ` Pedro Alves
2008-04-12  0:19                 ` Pedro Alves
2008-04-13  9:35                   ` Pedro Alves
2008-04-13 13:40                     ` Pedro Alves
2008-04-12 16:38           ` Roland McGrath
2008-04-12 16:43           ` Eli Zaretskii

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=200706271601.l5RG1KoT030784@brahms.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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