Memory corruption in bochs and virtualbox?

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
dragonfire353
Posts: 13
Joined: Tue Oct 01, 2013 11:45 pm

Memory corruption in bochs and virtualbox?

Post by dragonfire353 »

Alright, so I'm attempting to do an 64bit os completely in assembly, right now just trying to make a cli for fun before I move onto the hard stuff lol (I've just gotten to 64 bit).

The problem is that it appears memory is getting corrupted or overwritten by the bios. It happens in around the ~(8100h-8600h) memory range I believe.

I believe this because if I delete some necessary code below it, then the cli works as expected, else my key to ascii map gets corrupted or the actual cli code gets corrupted and causes a triple fault (depending on how much code I have in the file upon compilation at a time). I thought we had up to 9000:FBFF until the extended bios data area? My code is only around 32kb starting at the regular 0:7C00 and the lower memory detection (ax = 0, int 12h) returns 63kb.

I'm using fasm and this happens in both bochs and vbox

Any help appreciated, hope I supplied enough information! :)
Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Memory corruption in bochs and virtualbox?

Post by Octocontrabass »

dragonfire353 wrote:the lower memory detection (ax = 0, int 12h) returns 63kb.
Are you sure?
dragonfire353
Posts: 13
Joined: Tue Oct 01, 2013 11:45 pm

Re: Memory corruption in bochs and virtualbox?

Post by dragonfire353 »

Octocontrabass wrote:
dragonfire353 wrote:the lower memory detection (ax = 0, int 12h) returns 63kb.
Are you sure?
Sorry, meant 639kb: https://www.dropbox.com/s/rb1v866xlyr7v ... .59.01.png
Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Memory corruption in bochs and virtualbox?

Post by Octocontrabass »

It sounds like a bug in your code. (Shocking! But, we all make mistakes. I know I've made some errors that were really dumb in retrospect.)

First, check to be sure that whatever loads that code into memory is loading it correctly. You can use magic breakpoints in Bochs to halt right after loading should be finished, then examine the contents of memory. Is everything where it's supposed to be?

If everything is being loaded correctly and the corruption comes later, add a few more magic breakpoints and see if you can narrow down the problem to a specific part of your code.

Finally, if you still can't find the problem, tell us what debugging steps you've already taken and what the results were. If you've narrowed down the problem to a small section of code, be sure to include it in your post.
dragonfire353
Posts: 13
Joined: Tue Oct 01, 2013 11:45 pm

Re: Memory corruption in bochs and virtualbox?

Post by dragonfire353 »

Octocontrabass wrote:It sounds like a bug in your code. (Shocking! But, we all make mistakes. I know I've made some errors that were really dumb in retrospect.)

First, check to be sure that whatever loads that code into memory is loading it correctly. You can use magic breakpoints in Bochs to halt right after loading should be finished, then examine the contents of memory. Is everything where it's supposed to be?

If everything is being loaded correctly and the corruption comes later, add a few more magic breakpoints and see if you can narrow down the problem to a specific part of your code.

Finally, if you still can't find the problem, tell us what debugging steps you've already taken and what the results were. If you've narrowed down the problem to a small section of code, be sure to include it in your post.
Lol thank you, I figured this but I was asking in case I was mistaken about the free memory, something I didn't know. I know how to set breakpoints with linear addresses which isn't entirely effective when you don't know the exact address where you want to break, also when there's interrupts you have to step through.... so... I guess I'll look into this "magic breakpoint" that I have not heard before. TY
Post Reply