From 4bce33009891a04bcc0bbe736ba2d0daf8536bf5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 5 Aug 2003 10:52:34 -0700 Subject: [PATCH] [PATCH] fix spinlock deadlock in ptrace-reaping of detached thread When a dead detached thread has been temporarily zombified because it's ptraced and its tracer tries to reap it, it deadlocks on SMP. Here's the fix. --- kernel/exit.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index d5f45b814d1fe..a7328cc9992bf 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -898,13 +898,19 @@ static int wait_task_zombie(task_t *p, unsigned int *stat_addr, struct rusage *r __ptrace_unlink(p); p->state = TASK_ZOMBIE; /* If this is a detached thread, this is where it goes away. */ - if (p->exit_signal == -1) + if (p->exit_signal == -1) { + /* release_task takes the lock itself. */ + write_unlock_irq(&tasklist_lock); release_task (p); - else + } + else { do_notify_parent(p, p->exit_signal); + write_unlock_irq(&tasklist_lock); + } p = NULL; } - write_unlock_irq(&tasklist_lock); + else + write_unlock_irq(&tasklist_lock); } if (p != NULL) release_task(p); -- 2.53.0