All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@debian.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Roland McGrath <roland@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: Re: More waitpid issues with CLONE_DETACHED/CLONE_THREAD
Date: Sat, 31 Jan 2004 23:43:31 -0500	[thread overview]
Message-ID: <20040201044331.GA27271@nevyn.them.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0401312014420.2033@home.osdl.org>

On Sat, Jan 31, 2004 at 08:38:43PM -0800, Linus Torvalds wrote:
> 
> 
> On Sat, 31 Jan 2004, Daniel Jacobowitz wrote:
> >
> > This may be related to the python bug reported today...
> 
> Indeed.
> 
> Having a "waitpid(x, .., WNOHANG)" return 0 is a very interesting 
> condition. That condition basically guarantees that:
> 
>  - the kernel did find the child
>  - but the kernel decided that the child cannot be reaped right then.
> 
> If you see the process as a Zombie in a "ps" listing, then we know that 
> that isn't the reason why it couldn't be reaped. Can you verify that 
> /proc/<pid>/status shows it as "Z (zombie)"?

Yes, it is a zombie when the waitpid is executed.

> In fact, if we see it as "Z (zombie)", we know even more: it means that 
> wait_task_zombie() was never called, because that would have started out 
> with changing the process state to "X (dead)".
> 
> And that in turn implies that "eligible_child()" would have returned 2.
> 
> Which is a normal occurrence: it happens when a process group leader still 
> has threads attached to it. At that point it may be a Zombie, but we can't 
> reap it yet. The threads have to go away before the thing can be reaped.
> 
> Can you verify that that process doesn't have any sub-threads? (Again, 
> that should be easily visible in /proc/<pid>/task/).

It is quite easily visible - in fact, it's hilarious.

 8454 pts/8    Z      0:00 [linux-dp] <defunct>

drow@nevyn:~% ls /proc/8454
auxv  cmdline  cwd@  environ  exe@  fd/  maps  mem  mounts  root@  stat

drow@nevyn:~% ls /proc/8454/task
ls: /proc/8454/task: No such file or directory

What that means I'm not entirely sure.

> Another alternative is that the process is a zombie, but it is being
> traced. When that happens, it shows up on the "ptrace_children" list, and
> we'll see in in wait4(), but we won't be able to reap it. 

At this point it is being traced - this is gdbserver.  But the same
process that is tracing it is calling waitpid.  And the problem
persists after the tracer dies; the process above is actually from a
couple of hours ago, and its tracer was killed.

> Roland, Ingo - have you followed the discussion on linux-kernel? Something 
> strange does seem to be going on..

The only two kernels I've tried were 2.6.0-test7 and 2.6.2-rc3, by the
way - same behavior in both.  I'll try to write a single program
testcase for this.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

  reply	other threads:[~2004-02-01  4:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-01  3:25 More waitpid issues with CLONE_DETACHED/CLONE_THREAD Daniel Jacobowitz
2004-02-01  4:38 ` Linus Torvalds
2004-02-01  4:43   ` Daniel Jacobowitz [this message]
2004-02-01  5:12     ` Daniel Jacobowitz
2004-02-01 21:41       ` Linus Torvalds
2004-02-01 22:25         ` Roland McGrath
2004-02-02  0:55           ` Linus Torvalds
2004-02-02  2:20             ` Andries Brouwer
2004-02-02  2:30               ` Linus Torvalds
2004-02-02  0:52         ` Daniel Jacobowitz
2004-02-02  2:41           ` Davide Libenzi
2004-02-02  2:55             ` Davide Libenzi
2004-02-04 14:22               ` fs/eventpoll : reduce sizeof(struct epitem) dada1
2004-02-05  4:23                 ` Davide Libenzi
2004-02-01  5:12     ` More waitpid issues with CLONE_DETACHED/CLONE_THREAD Linus Torvalds
2004-02-01  5:14       ` Daniel Jacobowitz
2004-02-01  5:42         ` Roland McGrath
2004-02-01  5:46           ` Daniel Jacobowitz

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=20040201044331.GA27271@nevyn.them.org \
    --to=dan@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.