Memory & Framebuffer Corruption Bug

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
torii
Posts: 18
Joined: Sun Feb 02, 2025 5:59 pm
GitHub: https://github.com/Toriiiiiiiiii
Contact:

Memory & Framebuffer Corruption Bug

Post by torii »

Hi all!
I am experiencing an issue that I believe may be related to faulty memory allocation. I have implemented a small driver that should allow my code to write to arbitrary positions on the Framebuffer. However, this seems to have uncovered an interesting bug that I cannot seem to track down.

Allocating memory seems to be corrupting the framebuffer memory - which I assume is due to liballoc allocating memory to the same address space as the Framebuffer itself. To try and resolve this, I implemented a check in my frame allocator to prevent it from allocating pages that (should) contain the framebuffer. However, this problem has not stopped.

Additionally, I appear to somehow be allocating memory that either cannot be written to, or gets overwritten almost instantly after (I can't really work out which), which is causing corruption in the memory buffer I have been writing to. (See below).

Does anyone have any idea what might be going on here?
(Github)
corruption.png
Writing bad code since 2019
Image
nullplan
Member
Member
Posts: 2034
Joined: Wed Aug 30, 2017 8:24 am

Re: Memory & Framebuffer Corruption Bug

Post by nullplan »

As far as I can tell, your allocator never actually reads in the memory map. It just starts allocating from end_kernel and goes forward from there. That is not a good thing. You should be telling the allocator to only use that memory which the memory map lists as usable RAM, and then subtract from that set the memory your kernel was loaded to.
Carpe diem!
Post Reply