'subpage_kfree' error while trying to clean up processes. We're having a hard time figuring out what it means.

panic: Assertion failed: fl != fl->next, at ../../vm/kmalloc.c:1182 (subpage_kfree)

We only started getting this once we started to cleanup our processes with proc_destroy. Obviously we’re doing something wrong/out of order but it’s pretty difficult to track down what the issue is when you don’t understand the nature of the error. kmalloc.c is exceedingly difficult to read.

May not be much of a help, but here goes –

I’ve found proc_destroy() to be very flakey, and have had better luck with manual cleanup. Part of the issue sometimes stems from cleaning up some goo in sys_exit(), some in sys_waitpid(), and other stuff in thread_exit(). You may have your own reasons for divvying the cleanup one way among the three–say, for performance–but this may not play nice with the ordering expected in proc_destroy(). YMMV.

1 Like

I have seen this assertion failed when you are trying to free some memory that was not actually allocated. Have a look at line in proc_destroy() which is causing this error(usually a call to kfree) and proceed accordingly. Hope this helps.


Alright thanks for the advice guys. We’re going to make some changes to our cleanup process, I’ll post back if I figure out what the problem was.

The solution involved nulling out the file table of each process when it’s created. It looks like our filetables were just grabbing junk memory or something.