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
Crash when casting a void* to a multiboot_info_t*
Re: Crash when casting a void* to a multiboot_info_t*
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.)
(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
http://users.atw.hu/gerigeri/DawnOS/download.html
Re: Crash when casting a void* to a multiboot_info_t*
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.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.)
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.
Re: Crash when casting a void* to a multiboot_info_t*
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
http://users.atw.hu/gerigeri/DawnOS/download.html
Re: Crash when casting a void* to a multiboot_info_t*
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.
Re: Crash when casting a void* to a multiboot_info_t*
Hi,
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:
..but that would just make the code a little cleaner.
Cheers,
Brendan
The problem is here (in "boot.s"):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
Code: Select all
_start:
mov $stack_top, %esp
push %ebp
push %eax
call kernel_main
Note that you can avoid casting by defining main like this:
Code: Select all
void kernel_main(uint32_t magic, multiboot_info_t* header) {
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.
Re: Crash when casting a void* to a multiboot_info_t*
Thank you for helping Brendan but I solved my issue right before you posted. Still thanks for advice and help.
Working on managarm.