git: 9front

Download patch

ref: a2f934209e5ddc46f7af3d429d86da032a7aca45
parent: f4690f92b3e8d4a5c6d97c58d41218ade94e9901
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Nov 7 00:21:42 EST 2014

devproc: reset p->pdbg under p->debug qlock in procstopwait()

theres a race where procstopwait() is interrupted by a note,
setting p->pdbg to nil *before* acquiering the lock and
and pexit() and procctl() accessing it assuming it doesnt
change under them while they are holding the lock.

--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -1258,8 +1258,8 @@
 	qunlock(&p->debug);
 	up->psstate = "Stopwait";
 	if(waserror()) {
-		p->pdbg = nil;
 		qlock(&p->debug);
+		p->pdbg = nil;
 		nexterror();
 	}
 	sleep(&up->sleep, procstopped, p);
--