Skip to content

Boot stack (0x90000) is never reserved in the PMM #109

Description

@kudasaixc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions