--- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -188,6 +188,7 @@ suspend_kproc(struct thread *td, int timo) { if (td->td_proc == NULL) { + lwkt_hold(td); /* prevent exit/reuse during the protocol */ lwkt_gettoken(&kpsus_token); /* request thread pause */ atomic_set_int(&td->td_mpflags, TDF_MP_STOPREQ); @@ -199,6 +200,7 @@ } atomic_clear_int(&td->td_mpflags, TDF_MP_STOPREQ); lwkt_reltoken(&kpsus_token); + lwkt_rele(td); return(0); } else { return(EINVAL); /* not a kernel thread */