Bug 13164

Summary: kthread_exit stops, but doesn't release process context
Product: Base System Reporter: anderson <anderson>
Component: kernAssignee: John Baldwin <jhb>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-CURRENT   
Hardware: Any   
OS: Any   

Description anderson 1999-08-15 21:20:01 UTC
calling kthread_exit leaves the kthread_create'd processes in zombie state.

If those dead threads were created by a kernel module and the module is
unloaded, "w" (more specifically kern_proc.c line 452) can crash the system
when it tries to examine the dead thread's wait channel that points off
into unloaded module vacuum.

Fix: 

I've added "RFNOWAIT" to the kthread_create fork1 flags.  This
causes the threads to adopt init as their parent and go away cleanly after
a kthread_exit.
How-To-Repeat: create a kernel thread with "kthread_create" and have it "kthread_exit."
the process context lingers.
Comment 1 Jason Evans freebsd_committer freebsd_triage 2000-10-23 22:37:23 UTC
Responsible Changed
From-To: freebsd-bugs->jhb

jhb has recently done some work in -current that should fix this. 
Comment 2 John Baldwin freebsd_committer freebsd_triage 2001-03-11 01:50:01 UTC
State Changed
From-To: open->closed

This was fixed a few months ago in current and MFC'd a few weeks ago. 
Rather than creating kthreads with RFNOWAIT, which reparents the 
process to init during fork, I did an explicit reparent in kthread_exit. 
This way, kernel threads had a parent process of proc0 while they were 
executing since it would just be weird to have kernel threads children 
of a userland process.