Kernel: Heap alignment bug - #45
Merged
Merged
Conversation
sohshri796-cell
force-pushed
the
kernel/heap
branch
from
July 31, 2026 06:33
ee0a359 to
5ba54de
Compare
Signed-off-by: Soham Aney <sohshri796@gmail.com>
sohshri796-cell
force-pushed
the
kernel/heap
branch
from
July 31, 2026 06:38
5ba54de to
29825c2
Compare
Owner
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's a bug when allocating memory in heap.c.
The memory we allocated wasnt aligned as the mcu needs it to be. So i modified the file to allocate the memory in only multiples of 8. So it allocates memory interms of nearest higher multiple of 8.
This needs to be done as without proper alignment if user asks for some memory which isnt multiple of 4, the cpu stalls due to unaligned memory access.
It allocates memory in multiples of 8 rather than in 4's is because if we ever need other data types like
doublewhich need more than 4 bytes of space.I tested this using this code snippet:
when we run this without proper alignment in memory it would just stall.

I tested this on both hardware as well as QEMU.