When I attempt to fork, the child process throws interrupt 6 after returning to the calling function. After a bit of debugging, I believe the problem is in the stack:
If I copy the stack to a new location during fork, it will work (although it will not fork again)
If I take the code from fork and copy it into the calling function, it will work.
Currently my fork clones the current directory. I thought this would copy over the stack, but seeing as I still get interrupt 6 regardless of whether I clone the current directory or not, it appears I'm looking in the wrong place.
Any pointers on how to fix this? Do I need to provide any more information?
Interrupt 6 on fork
Re: Interrupt 6 on fork
I assumed so, but even if I don't clone the current directory I still have the same problem. Perhaps it's not the stack, then.berkus wrote:A clone of current directory would point into the same place for the stack, wouldn't it?
Re: Interrupt 6 on fork
Am I reading this correctly and you have two threads using the same stack?RobertF wrote:When I attempt to fork, the child process throws interrupt 6 after returning to the calling function. After a bit of debugging, I believe the problem is in the stack:
If I copy the stack to a new location during fork, it will work (although it will not fork again)
If I take the code from fork and copy it into the calling function, it will work.
Currently my fork clones the current directory. I thought this would copy over the stack, but seeing as I still get interrupt 6 regardless of whether I clone the current directory or not, it appears I'm looking in the wrong place.
Any pointers on how to fix this? Do I need to provide any more information?
Re: Interrupt 6 on fork
The new thread takes the esp and ebp from the parent thread, but I'm not physically copying the parent's stack to the childs.JamesM wrote:Am I reading this correctly and you have two threads using the same stack?
Also, my fork had a while loop at the end; removing this caused interrupt 13 instead of interrupt 6. I've also found that if I use GRUB's stack instead of setting one up before I call the kernel's main, I'll page fault instead of generating any interrupts.
Re: Interrupt 6 on fork
Turns out I was cloning the page directory incorrectly (as berkus hinted)—doesn't mean I fixed this yet, but it's a lot more satisfying to have a problem and know where it is rather than being completely baffled by it.