loader.s sets esp to 0x90000, which lies in conventional memory that init_mem() marks as free (it is part of a multiboot AVAILABLE region). pmm_alloc_frame() hands out the lowest free frame first, so once the heap has consumed enough low frames the allocator will eventually return the frames right under the active stack. They then get mapped into the heap, and the next malloc write corrupts the stack -- random crashes that are very hard to trace back.
Possible fixes:
- reserve the region in
init_mem() (e.g. pmm_mark_region_used(0x80000, 0x10000);), or
- move the stack into the kernel image (linker-provided symbol) so the existing kernel reservation covers it.
Happy to send a PR for whichever approach you prefer.
loader.ssetsespto0x90000, which lies in conventional memory thatinit_mem()marks as free (it is part of a multiboot AVAILABLE region).pmm_alloc_frame()hands out the lowest free frame first, so once the heap has consumed enough low frames the allocator will eventually return the frames right under the active stack. They then get mapped into the heap, and the nextmallocwrite corrupts the stack -- random crashes that are very hard to trace back.Possible fixes:
init_mem()(e.g.pmm_mark_region_used(0x80000, 0x10000);), orHappy to send a PR for whichever approach you prefer.