Forkbomb error


(Rachel Ann Roberts) #1

When thread fork fails, we are trying to call proc_destroy on our newly created child process because there isn’t enough memory for it, but it fails a KASSERT of pnumthreads == 0 in proc_destroy. We also tried calling thread_exit to get rid of that thread, but that doesn’t work either. What needs to be done to clean up the process?


(Benjamin Bell) #2

Not really much to go on there but supposedly if thread_fork fails then the number of threads for the new proc you created (and passed to thread fork) should be zero anyways. Maybe something wrong with your proc_create?
Check where pnumthreads is being incremented.


(Rachel Ann Roberts) #3

when we create our child process in fork (before we call thread fork), we set child proc’s pnumthreads to the curproc’s pnumthreads, which i assume is one.


(Benjamin Bell) #4

There is no need to do that. If you look at the code for thread_fork you’ll notice it calls proc_addthread which increments p_numthreads.

Edit: Also you shouldn’t set the child proc’s pnumthreads to curproc threads because you are only forking a single thread, the one calling fork.