xv6-riscv icon indicating copy to clipboard operation
xv6-riscv copied to clipboard

bug?: kfree the same page twice

Open qin-you opened this issue 2 years ago • 1 comments

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.

qin-you avatar Jul 06 '23 08:07 qin-you

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.

jduck avatar Dec 21 '24 20:12 jduck

Closing expired issue

kaashoek avatar Aug 07 '25 23:08 kaashoek