I passed every test except the randcall test, if I run the test as a standalone test
test161 run stability/randcall.t I pass the test every time. When I run it as a whole it fails with unexpected shutdown.
I then ran it from the shell as
/testbin/randcall -f 2, this passes with no problem at all. However when I run it without suppressing fork it fails with fork: out of memory.
Using gdb I tracked the issue to
thread_create that is called by
thread_fork in my
thread_create fails when attempting to allocate space for the thread stack.
I noticed the comments for
thread_exit say that threads leak memory and will cause some test161 checks to fail but i’m not convinced this is why fork is running out of memory.
I have written unit tests for the table structure/api I use for my file handle table and process table and I am sure they are not leaking any memory. I’ve gone through all the code I wrote and made sure all kmallocs have equivalent kfrees somewhere.
Yet I know for sure that I am leaking memory because everytime I run a test from the kernel menu that uses fork, khu increases by 176. There is an orphaned process, the first process that runs in userspace that remains a zombie process until shutdown but only the bare bones of that proc are left
sizeof(struct proc) = 56. So that leaves me with 120bytes leaking from somewhere.
But even in the case where everytime fork is called with a matching waitpid, leaking 120bytes; this shouldn’t cause fork to run out of memory.
Also when fork runs out of memory in the shell, if I quit the shell (freeing the 4096bytes of space allocated for the shell’s process’ stack, when I try to run the shell again from the kernel cmdline, it fails with fork out of memory again.
Any ideas for solving this would be much appreciated