James Molloy's Tutorial Known Bugs: Difference between revisions

Jump to navigation Jump to search
Moved heap bug details from the user mode section to the heap section
[unchecked revision][unchecked revision]
m (renamed real mode to user mode)
(Moved heap bug details from the user mode section to the heap section)
Line 82:
 
It is probably best that you write your own heap implementation.
 
There is an operator precedence bug in <tt>find_smallest_hole()</tt> that will cause bad allocations and memory overwrites if attempting to fork in user mode later on.
 
To fix the problem, change this:
<nowiki>
if ((location+sizeof(header_t) & 0xFFFFF000) != 0)</nowiki>
 
to this:
<nowiki>
if (((location+sizeof(header_t)) & 0xFFFFF000) != 0)</nowiki>
 
See the section on user mode below for more details.
 
== Problem: VFS Code ==
Line 237 ⟶ 249:
set_kernel_stack(current_task->kernel_stack+KERNEL_STACK_SIZE);</nowiki>
 
=== Problem 5: Operator precedencefind_smallest_hole() bug in find_smallest_holeheap code causing fork() to page fault ===
 
There is an operator precedenceThis bug infrom <tt>find_smallest_hole()</tt>the thatheap willchapter causemay badnot allocationshit andyou memoryuntil overwritesnow. ifThe attempting to fork. Thisbug results in the newly allocated <tt>kernel_stack</tt> messing up the page directory, causing <tt>clone_directory()</tt> to fail in <tt>fork()</tt>. See the heap section above for the details.
 
To fix the problem, change this:
<nowiki>
if ((location+sizeof(header_t) & 0xFFFFF000) != 0)</nowiki>
 
to this:
<nowiki>
if (((location+sizeof(header_t)) & 0xFFFFF000) != 0)</nowiki>
 
== Conclusion ==
5

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu