pwait(): ...
sleep(&up->waitr, haswaitq, up);
lock(&up->exl);
wq = up->waitq;
up->waitq = wq->next; <-- wq == nil, boom! its gone!
up->nwait--;
unlock(&up->exl);
if sleep returns or is spuriously woken up even tho up->waitq == nil.
--
cinap
