xv6-riscv
xv6-riscv copied to clipboard
bug?: kfree the same page twice
in kernel/proc.c freeproc() function :
kfree((void*)p->trapframe); // first
proc_freepagetable(p->pagetable, p->sz);
uvmunmap(pagetable, TRAPFRAME, 1, 0);
kfree((void*)pa); // second
kfree will not give up this duplicated page, and this could lead to some problems. I delete the first kfree above and the code works well.
This doesn't make much sense because the final argument to uvmunmap dictates whether or not that kfree is called. As you can see here, it's passed a zero for do_free arg.
Closing expired issue