linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Casasnovas <quentin.casasnovas-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Denys Vlasenko <dvlasenk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Quentin Casasnovas
	<quentin.casasnovas-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	"Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Vegard Nossum
	<vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: ptrace.2: BUGS (missing WIFEXITED notification)
Date: Thu, 14 May 2015 19:41:23 +0200	[thread overview]
Message-ID: <20150514174123.GC13385@chrystal.uk.oracle.com> (raw)
In-Reply-To: <5554D5F8.8050305-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Thu, May 14, 2015 at 07:06:00PM +0200, Denys Vlasenko wrote:
> On 05/14/2015 06:50 PM, Quentin Casasnovas wrote:
> >>> The only way for us to work-around this behaviour was to have
> >>> PTRACE_O_TRACEEXIT and detach from the threads when we were notified of a
> >>> thread termination, without PTRACE_O_TRACEEXIT I don't think one can be
> >>> notified in way, leading to hangs almost certainly when tracing multiple
> >>> threads and some are in ptrace-stop.
> >>
> >> Why do you do that waitpid on thread group leader?
> >>
> >> strace is the user of ptrace, and it has no problem with this behavior.
> >> It simply waits for all tracees via waitpid(-1). Whichever sends the next
> >> notification is processed.
> >>
> > 
> > That's because strace has all threads running; in our use-case, we attach
> > to all threads of a group and restart a single thread to do some work.  In
> > this particular case, waitpid(-1, ...) does not help because to exit, the
> > other threads need to be PTRACE_CONT'ed.
> 
> Can you be more specific?
> IF you have thread(s) which "do some work", then waitpid(-1) would work
> for you - presumably, you wait for them to finish doing work,
> or otherwise terminate, get a signal, whatever?

Oh you are right, PEBCAK!  It would appear I did not test this properly, I
cannot reproduce this behaviour...

So, if we attach to all threads of a group, call them thread A and B, then
CONT thread A, which then terminates for any reason, doing a waitpid(-1)
will indeed notify us for the termination even though thread B is in
ptrace-stop.

Sorry for the noise.

Quentin
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-05-14 17:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:31 ptrace.2: BUGS (missing WIFEXITED notification) Vegard Nossum
     [not found] ` <55520EAC.2010003-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-05-14 13:44   ` Michael Kerrisk (man-pages)
     [not found]     ` <5554A6B0.2090409-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-05-14 13:52       ` Denys Vlasenko
     [not found]         ` <5554A8A4.7060404-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-14 16:28           ` Quentin Casasnovas
     [not found]             ` <20150514162807.GA13385-Cuu6V/XUcleLI2c71l+0mdkmqwFzkYv6@public.gmane.org>
2015-05-14 16:39               ` Denys Vlasenko
     [not found]                 ` <5554CFDF.6070602-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-14 16:50                   ` Quentin Casasnovas
     [not found]                     ` <20150514165031.GB13385-Cuu6V/XUcleLI2c71l+0mdkmqwFzkYv6@public.gmane.org>
2015-05-14 17:06                       ` Denys Vlasenko
     [not found]                         ` <5554D5F8.8050305-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-14 17:41                           ` Quentin Casasnovas [this message]
2015-05-15 10:12                   ` Vegard Nossum
     [not found]                     ` <5555C69A.3070509-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-05-15 12:05                       ` Michael Kerrisk (man-pages)
     [not found]                         ` <CAKgNAkixHtPEdmwuVhic8k2gz8ooLmW1rJ3760oWGUC07K-5hg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-18  6:49                           ` Michael Kerrisk (man-pages)
     [not found]                             ` <55826A17.8000804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-12 14:50                               ` Vegard Nossum
     [not found]                                 ` <57ADE23B.8050905-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-08-12 16:15                                   ` Denys Vlasenko
     [not found]                                     ` <864524d3-6a7f-9555-b4a4-eb4816c4da18-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-08-12 18:37                                       ` Vegard Nossum
     [not found]                                         ` <57AE1750.50303-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-08-12 19:11                                           ` Denys Vlasenko

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=20150514174123.GC13385@chrystal.uk.oracle.com \
    --to=quentin.casasnovas-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=dvlasenk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.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 NNTP newsgroup(s).