From 7ce60f6013d517e6a6cb29fd2670ff5a6acbfeaa Mon Sep 17 00:00:00 2001 From: David Xu Date: Tue, 10 Jul 2012 05:45:13 +0000 Subject: [PATCH] Always clear p_xthread if current thread no longer needs it, in theory, if debugger exited without calling ptrace(PT_DETACH), there is a time window that the p_xthread may be pointing to non-existing thread, in practical, this is not a problem because child process soon will be killed by parent process. --- sys/kern/kern_sig.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 52a0c405713..2685a8b1384 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2436,9 +2436,10 @@ ptracestop(struct thread *td, int sig) } stopme: thread_suspend_switch(td); - if (!(p->p_flag & P_TRACED)) { + if (p->p_xthread == td) + p->p_xthread = NULL; + if (!(p->p_flag & P_TRACED)) break; - } if (td->td_dbgflags & TDB_SUSPEND) { if (p->p_flag & P_SINGLE_EXIT) break;