OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 3:07 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Undefined Behaviour when creating new processes
PostPosted: Mon Sep 03, 2018 2:47 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
Hello,
I am currently in the stage of an OS where a shell is being run, but when spawning new processes via syscalls undefined behaviour happens. When spawning a process loaded from the initrd it tries to access the addresses 0xFFFFFFFF and 0x83042000 and it also interrupted interrupt vector 255 but i have not set that vector. after mapping the previously named addresses to 0x0 it ran, but when i try to run it a second time qemu aborts and bochs has a 3rd exception with no resolution. After trying a lot of different things I cannot figure out why this behaviour happens, so I hope someone is able to help me resolve this.

Source: https://github.com/thomtl/Project-Rhino

The code that spawns the process is in src/kernel/user/init.c void create_process(char* prg) at line 71 the two address workaround lines can be seen at line 84 and 85.

The shell is located at utils/TSH and the process that is being spawned is at utils/UserTest

Documentation for syscalls is at doc/syscalls.txt

To build it Make assumes yasm and i686-elf-gcc are in your PATH and you need to go to utils/TSH and make that then go to utils/UserTest and make that and then you can go back to the root and make that

I'm sorry that I am not able to supply more information about the problem and that my English is not that good.

-thomtl


Top
 Profile  
 
 Post subject: Re: Undefined Behaviour when creating new processes
PostPosted: Fri Sep 07, 2018 6:11 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
bump


Top
 Profile  
 
 Post subject: Re: Undefined Behaviour when creating new processes
PostPosted: Fri Sep 07, 2018 2:29 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
Unless you happen to know the address of the code you are trying to troubleshoot, you may want to add a "Magic Breakpoint".

https://wiki.osdev.org/Bochs#Magic_Breakpoint

By adding a specific ASM instruction, and enabling magic breakpoints in Bochs, you can get Bochs to break at a specific instruction, and you can walk through the next few instructions one at a time, and see what is happening.

Once you get into multi-threading in your OS, you really need to have a good debugging solution in place. It's quite difficult to proceed without one.

_________________
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott


Top
 Profile  
 
 Post subject: Re: Undefined Behaviour when creating new processes
PostPosted: Sat Sep 08, 2018 8:34 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
Hello,
I have figured it out, I was allocating to much space for the stack in the process which in turn led to it running out of space and there not being a valid stack.
Thanks SpyderTL your tip about Magic Breakpoints led me to the stack being corrupted. It works perfectly now.
-thomtl


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], SemrushBot [Bot] and 95 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