linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Pavel Machek <pavel@ucw.cz>, Denys Vlasenko <dvlasenk@redhat.com>,
	jan.kratochvil@redhat.com, palves@redhat.com,
	Roland McGrath <roland@hack.frob.com>,
	syzkaller <syzkaller@googlegroups.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Unkillable processes due to PTRACE_TRACEME again
Date: Mon, 5 Dec 2016 12:00:17 +0100	[thread overview]
Message-ID: <20161205110016.GA29776@redhat.com> (raw)
In-Reply-To: <20161205104652.GA29197@redhat.com>

On 12/05, Oleg Nesterov wrote:
>
> On 12/02, Dmitry Vyukov wrote:
> >
> > I am not on 2caceb3294a78c389b462e7e236a4e744a53a474 (Dec 1). And see
> > the same unwaitable zombie processes.
>
> This is another thing, and notabug. This is how ptrace works,
>
> > void *thr(void *arg)
> > {
> >   ptrace(PTRACE_TRACEME, 0, 0, 0);
> > }
> >
> > int main()
> > {
> >   int pid = fork();
> >   if (pid == 0) {
> >     pthread_t th;
> >     pthread_create(&th, 0, thr, 0);
> >     usleep(100000);
> >     exit(0);
> >   }
> >   usleep(200000);
> >   kill(pid, SIGKILL);
> >   int status = 0;
> >   waitpid(pid, &status, __WALL);
>
> waitpid(pid) hangs because you need to reap the sub-thread first.

I'm afraid I wasn't clear...

So the child process has 2 threads, the leader thread L and the sub-thread T.
waitpid(pid == L->pid) will block until all the threads go away, but since T is
traced it won't autoreap, the tracer should do waitpid(T->pid) first to reap
this zombie. waitpid(-1) should work too.

Oleg.

  reply	other threads:[~2016-12-05 11:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02 18:48 Unkillable processes due to PTRACE_TRACEME again Dmitry Vyukov
2016-12-02 21:02 ` Pavel Machek
2016-12-03 15:55   ` Dmitry Vyukov
2016-12-03 19:11     ` Pavel Machek
2016-12-05 10:46 ` Oleg Nesterov
2016-12-05 11:00   ` Oleg Nesterov [this message]
2016-12-05 14:07     ` Dmitry Vyukov
2016-12-05 16:59       ` Oleg Nesterov

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=20161205110016.GA29776@redhat.com \
    --to=oleg@redhat.com \
    --cc=dvlasenk@redhat.com \
    --cc=dvyukov@google.com \
    --cc=jan.kratochvil@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=palves@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=roland@hack.frob.com \
    --cc=syzkaller@googlegroups.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;
as well as URLs for NNTP newsgroup(s).