OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:32 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Something overwrittes memory after address space mapping
PostPosted: Sun Apr 25, 2021 11:05 am 
Offline

Joined: Sun Apr 25, 2021 9:55 am
Posts: 2
Hi,
There is a small operating system I developed. I try to implement multitasking in kernel mode. I load my exe file into memory with dma controller and floppy disk. I hardcoded physical address 0x20000 for my program (I've tryed other addresses, it doesn't matter). If I do identity mapping of the first megabyte and start new process with the EIP register that is equal 0x20000 everything is fine. It works as expected. When I try to map 0x20000 of physical memory to 0 address of virtual address space something happens. Something overwrite 0x20000 physical memory address. I tryed analyze it, I tryed to find a bug in my code I didn't have any result. I hope somebody faced something similar. Thank you!
P.S. I attached normal and overwritted memory screenshots.


Attachments:
File comment: Overwritten memory
overwritten.png
overwritten.png [ 57.45 KiB | Viewed 1486 times ]
File comment: Good memory
good.png
good.png [ 72.34 KiB | Viewed 1486 times ]
Top
 Profile  
 
 Post subject: Re: Something overwrittes memory after address space mapping
PostPosted: Mon Apr 26, 2021 9:29 am 
Offline
Member
Member

Joined: Tue Aug 11, 2020 12:14 pm
Posts: 151
It sounds like you may be dereferencing a null pointer and overwriting something you don't want to overwrite.

As a matter of practice, it's usually good to make virtual address 0 unusable, for exactly this reason. You may want to try either removing the mapping for that address, or at least set it read-only and see what happens.


Top
 Profile  
 
 Post subject: Re: Something overwrittes memory after address space mapping
PostPosted: Tue Apr 27, 2021 2:26 am 
Offline

Joined: Sun Apr 25, 2021 9:55 am
Posts: 2
Thanks a lot! When I made memory read only I faced with another issue, but moving of memory mapping helped me! I tried to use virtual address 1 instead of virtual address 0 and it started to work. \:D/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], thewrongchristian and 83 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group