NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/50308: PS_STOPEXIT processes don't correctly handle b_nstopchild



The following reply was made to PR kern/50308; it has been noted by GNATS.

From: Paul Goyette <paul%vps1.whooppee.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/50308: PS_STOPEXIT processes don't correctly handle
 b_nstopchild
Date: Fri, 9 Oct 2015 12:40:42 +0800 (PHT)

 The previously suggested patch is not quite correct, since there could
 be a deadlock waiting for the proc_lock mutex.  The following patch
 addresses this deadlock:
 
 diff -u -p -r1.245 kern_exit.c
 --- kern_exit.c 2 Oct 2015 16:54:15 -0000       1.245
 +++ kern_exit.c 9 Oct 2015 04:35:42 -0000
 @@ -227,7 +227,15 @@ exit1(struct lwp *l, int rv)
   	if (__predict_false(p->p_sflag & PS_STOPEXIT)) {
   		KERNEL_UNLOCK_ALL(l, &l->l_biglocks);
   		sigclearall(p, &contsigmask, &kq);
 +
 +		if (!mutex_tryenter(proc_lock)) {
 +			mutex_exit(p->p_lock);
 +			mutex_enter(proc_lock);
 +			mutex_enter(p->p_lock);
 +		}
   		p->p_waited = 0;
 +		p->p_pptr->p_nstopchild++;
 +		mutex_exit(proc_lock);
   		membar_producer();
   		p->p_stat = SSTOP;
   		lwp_lock(l);
 
 Additionally, I question whether or not the call to membar_producer()
 is still required here, after insert the appropriate mutex code?
 
 
 
 +------------------+--------------------------+-------------------------+
 | Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
 | (Retired)        | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
 | Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
 +------------------+--------------------------+-------------------------+
 



Home | Main Index | Thread Index | Old Index