OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 5:12 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 10:54 am 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
Hello. I'm developing an OS. I get a very weird issue. When I cast void* passed as argument to kernel_main I get a very weird crash. EBX, ESI and EIP are set to a very similar value. Every time EIP is set to the same value(0x31303131) which results in a crash because of code executing outside of ROM or RAM. Source code.
PS. I'm using GRUB 2

_________________
Working on managarm.


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:01 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
you cant get crash from casting a void pointer to something. thats just giving a value to something. either the target variable, or the source is not a valid memory location.

(your project, kuki means small penis (boys penis) in hungarian language.)

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:10 am 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
Geri wrote:
you cant get crash from casting a void pointer to something. thats just giving a value to something. either the target variable, or the source is not a valid memory location.

(your project, kuki means small penis (boys penis) in hungarian language.)


I isolated the problem to be that one line(I tried it without anything before and after) and the EIP still was corrupted. How can I check the value if it doesn't get past that line.
KukkiOS is because Git doesn't really like non-ASCII characters(same with text mode). The correct OS name is クッキーOS or Kukkī OS(notice the i is not really an i, it's ī).

_________________
Working on managarm.


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:14 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
how do you know if you even have a proper stack pointer? are you sure you even have the right code origin?

_________________
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:16 am 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
I fixed the issue. I just realized I pushed EBP instead of EBX. My bad. Sorry if I wasted anyone's time.

_________________
Working on managarm.


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:18 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

qookie wrote:
Hello. I'm developing an OS. I get a very weird issue. When I cast void* passed as argument to kernel_main I get a very weird crash. EBX, ESI and EIP are set to a very similar value. Every time EIP is set to the same value(0x31303131) which results in a crash because of code executing outside of ROM or RAM. Source code.
PS. I'm using GRUB 2


The problem is here (in "boot.s"):
Code:
_start:
   mov $stack_top, %esp
   push %ebp
   push %eax
   
   call kernel_main

The address of the multiboot info is passed (by the boot loader) in EBX, not in EBP.

Note that you can avoid casting by defining main like this:
Code:
void kernel_main(uint32_t magic, multiboot_info_t* header) {

..but that would just make the code a little cleaner.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: Crash when casting a void* to a multiboot_info_t*
PostPosted: Sun May 14, 2017 11:21 am 
Offline
Member
Member
User avatar

Joined: Sun Apr 30, 2017 12:16 pm
Posts: 68
Location: Poland
Thank you for helping Brendan but I solved my issue right before you posted. Still thanks for advice and help.

_________________
Working on managarm.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 619 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