Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heap allocator bug #1067

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

tsoutsman
Copy link
Member

The implementation of GlobalAlloc for Heap assumed that all memory under INITIAL_HEAP_END_ADDR was allocated using the initial allocator, but this isn't true.

MultipleHeaps allocates large objects using mapped pages leading to objects allocated in the lower half of memory. When deallocating these objects, Heap tried to deallocate them using the initial allocator rather than MultipleHeaps.

The implementation of `GlobalAlloc` for `Heap` assumed that all memory
under `INITIAL_HEAP_END_ADDR` was allocated using the initial allocator,
but this isn't true.

`MultipleHeaps` allocates large objects using mapped pages leading to
objects allocated in the lower half of memory. When deallocating these
objects, `Heap` tried to deallocate them using the initial allocator
rather than `MultipleHeaps`.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down!

@kevinaboos kevinaboos merged commit bafc2e8 into theseus-os:theseus_main Oct 30, 2023
3 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 30, 2023
The implementation of `GlobalAlloc` for `Heap` assumed that all memory
under `INITIAL_HEAP_END_ADDR` was allocated using the initial allocator,
but this isn't true.

`MultipleHeaps` allocates large objects using mapped pages leading to
objects allocated in the lower half of memory. When deallocating these
objects, `Heap` tried to deallocate them using the initial allocator
rather than `MultipleHeaps`.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com> bafc2e8
github-actions bot pushed a commit to tsoutsman/Theseus that referenced this pull request Oct 31, 2023
The implementation of `GlobalAlloc` for `Heap` assumed that all memory
under `INITIAL_HEAP_END_ADDR` was allocated using the initial allocator,
but this isn't true.

`MultipleHeaps` allocates large objects using mapped pages leading to
objects allocated in the lower half of memory. When deallocating these
objects, `Heap` tried to deallocate them using the initial allocator
rather than `MultipleHeaps`.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com> bafc2e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants