mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Andrea Arcangeli <andrea@suse.de>
Cc: Andreas Schwab <schwab@suse.de>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>
Subject: Re: zombie with CLONE_THREAD
Date: Wed, 30 Jun 2004 20:22:25 -0700	[thread overview]
Message-ID: <200407010322.i613MPDr016785@magilla.sf.frob.com> (raw)
In-Reply-To: Andreas Schwab's message of  Wednesday, 30 June 2004 11:04:46 +0200 <je8ye5ct75.fsf@sykes.suse.de>

The reason strace hangs in that case is an strace bug.  strace is
blocking in a wait4 call on the specific PID of the zombie group leader,
which will never report until strace reaps the other non-leader thread
it is tracing.  But strace won't ever do that, because it's blocked
saying it only cares about the zombie leader's PID.  You should report
that bug in strace.  I pity the fool who agreed to maintain that unholy
pile of spaghetti--what a maroon!

The kernel bug is that when you kill strace, the non-leader zombie hangs
around and that keeps the zombie leader around too (which is the one
you'll see in ps).  The following patch fixes that for me.  I am not
100% confident that the locking dance required here doesn't create some
weird issue (and it certainly seems inefficient how many times the lock
is released and retaken in this sequence), but maybe 92% sure.


Thanks,
Roland


--- linux-2.6.7-mm4/kernel/exit.c.~1~	2004-06-30 16:29:06.000000000 -0700
+++ linux-2.6.7-mm4/kernel/exit.c	2004-06-30 18:55:36.000000000 -0700
@@ -618,9 +618,21 @@ static inline void forget_original_paren
 			reparent_thread(p, father, 0);
 		} else {
 			ptrace_unlink (p);
-			if (p->state == TASK_ZOMBIE && p->exit_signal != -1 &&
-			    thread_group_empty(p))
-				do_notify_parent(p, p->exit_signal);
+			if (p->state == TASK_ZOMBIE) {
+				if (p->exit_signal == -1) {
+					/*
+					 * This was only a zombie because
+					 * we were tracing it.  Now it should
+					 * disappear as it would have done
+					 * if we hadn't been tracing it.
+					 */
+					write_unlock_irq(&tasklist_lock);
+					release_task(p);
+					write_lock_irq(&tasklist_lock);
+				}
+				else if (thread_group_empty(p))
+					do_notify_parent(p, p->exit_signal);
+			}
 		}
 	}
 	list_for_each_safe(_p, _n, &father->ptrace_children) {



  reply	other threads:[~2004-07-01  3:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-30  6:00 Andrea Arcangeli
2004-06-30  6:08 ` Andrew Morton
2004-06-30  7:14   ` Roland McGrath
2004-06-30  9:04     ` Andreas Schwab
2004-07-01  3:22       ` Roland McGrath [this message]
2004-07-01  4:08         ` Andrea Arcangeli
2004-07-01  4:42           ` Linus Torvalds
2004-07-01  5:39           ` Roland McGrath
2004-07-01  5:56             ` Linus Torvalds
2004-07-01  7:06               ` Roland McGrath
2004-07-01 14:26                 ` Andrea Arcangeli
2004-07-01 21:33                   ` Roland McGrath
2004-07-01 15:49                 ` Linus Torvalds
2004-07-01 16:23                   ` Andrea Arcangeli
2004-07-01 16:43                     ` Linus Torvalds
2004-07-01 20:27                   ` Roland McGrath
2004-07-01  4:57         ` Linus Torvalds
2004-07-01  7:02           ` Roland McGrath
2004-07-01 16:50             ` Linus Torvalds

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=200407010322.i613MPDr016785@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=akpm@osdl.org \
    --cc=andrea@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®