Multitasking issues - Triple Fault for unknown reason
Posted: Thu Apr 04, 2024 11:50 pm
Hello again folks,
I've been struggling with multitasking yet again for the past week, and am completely stuck on a weird issue related to multitasking. At this point, I think I might be a bit out of my depth, so I would appreciate any and all help on this.
So far, I believe that:
- Task switching works properly. If I don't use the usermode process management functions such as execv, fork, and waitpid, everything appears to work perfectly fine.
- Something is very wrong, as I don't even get the "Kernel panic:\n" message in serial (which should be the very first thing it does).
- The issue has something to do with task switching, as single-stepping the code in GDB and setting breakpoints causes the issue not to occur. However, I don't know exactly where the issue lies.
To expand on that last one, for some reason, this issue is weird. It happens in Qemu but not Bochs, and occasionally will work without UEFI enabled. If single-stepping, it will work all the time, although I believe this is only because QEMU doesn't run interrupts the same way with GDB single-stepping.
One notable thing is that when I halt the program while it hangs after executing the command, but before it triple faults, it appears to be running some code up in the 0x770000 range (which shouldn't even be mapped in virtual memory?). When I backtrace with GDB, I get 2 calls at 0x20, which isn't an instruction address for either the shell or loaded program, so I have no idea how it ended up there, despite it looking like a valid location in memory.
Unfortunately, for now, that's all I've got. I'm completely lost trying to debug this, so if anyone is able to garner any insight from this, it would be much appreciated!
The current branch for the OS code is at:
https://github.com/Minater247/Xana3/tree/multitasking
Some notable files are:
process.c: https://github.com/Minater247/Xana3/blo ... /process.c
elf_loader.c: https://github.com/Minater247/Xana3/blo ... f_loader.c
All C code is located in /arch/x86_64/c/, and assembly in arch/x86_64/asm/.
And the current branch for the shell, in case it's helpful, is here:
https://github.com/Minater247/Xansh
The issue occurs when attempting to run any file from the shell - the provided XanHello.elf is a perfect example of the issue at hand. To test this, all that must be done after booting is typing `/mnt/ramdisk/bin/XanHello.elf` into the terminal.
If anything else would help, please let me know! I will try and provide anything else that would help in figuring this one out.
I've been struggling with multitasking yet again for the past week, and am completely stuck on a weird issue related to multitasking. At this point, I think I might be a bit out of my depth, so I would appreciate any and all help on this.
So far, I believe that:
- Task switching works properly. If I don't use the usermode process management functions such as execv, fork, and waitpid, everything appears to work perfectly fine.
- Something is very wrong, as I don't even get the "Kernel panic:\n" message in serial (which should be the very first thing it does).
- The issue has something to do with task switching, as single-stepping the code in GDB and setting breakpoints causes the issue not to occur. However, I don't know exactly where the issue lies.
To expand on that last one, for some reason, this issue is weird. It happens in Qemu but not Bochs, and occasionally will work without UEFI enabled. If single-stepping, it will work all the time, although I believe this is only because QEMU doesn't run interrupts the same way with GDB single-stepping.
One notable thing is that when I halt the program while it hangs after executing the command, but before it triple faults, it appears to be running some code up in the 0x770000 range (which shouldn't even be mapped in virtual memory?). When I backtrace with GDB, I get 2 calls at 0x20, which isn't an instruction address for either the shell or loaded program, so I have no idea how it ended up there, despite it looking like a valid location in memory.
Unfortunately, for now, that's all I've got. I'm completely lost trying to debug this, so if anyone is able to garner any insight from this, it would be much appreciated!
The current branch for the OS code is at:
https://github.com/Minater247/Xana3/tree/multitasking
Some notable files are:
process.c: https://github.com/Minater247/Xana3/blo ... /process.c
elf_loader.c: https://github.com/Minater247/Xana3/blo ... f_loader.c
All C code is located in /arch/x86_64/c/, and assembly in arch/x86_64/asm/.
And the current branch for the shell, in case it's helpful, is here:
https://github.com/Minater247/Xansh
The issue occurs when attempting to run any file from the shell - the provided XanHello.elf is a perfect example of the issue at hand. To test this, all that must be done after booting is typing `/mnt/ramdisk/bin/XanHello.elf` into the terminal.
If anything else would help, please let me know! I will try and provide anything else that would help in figuring this one out.