Instant general protection fault error code 1816
-
- Posts: 5
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Instant general protection fault error code 1816
Im was trying to implement keyboard input & interrupts but now i get infinite general protection fault errors and i cant seem to fix it.
code: https://github.com/Zeviraty/AOPOS
code: https://github.com/Zeviraty/AOPOS
-
- Member
- Posts: 223
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: Instant general protection fault error code 1816
In your isr_stubs.asm:
You define isr_stub_table within .text (in the code part of your executable), but only for 32 entries.
Directly afterwards you implement the code for the keyboard isr stub.
If you write data to isr_stub_table[32] you overwrite you keyboard isr stub.
You define isr_stub_table within .text (in the code part of your executable), but only for 32 entries.
Directly afterwards you implement the code for the keyboard isr stub.
If you write data to isr_stub_table[32] you overwrite you keyboard isr stub.
-
- Member
- Posts: 223
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: Instant general protection fault error code 1816
Ignore my last post. There is nothing wrong with the mentioned part. I would try to change the declaration of idt_entry *desc in your idt_set_descriptor function to volatile idt_entry *desc
Maybe the write of the values gets optimized away
Maybe the write of the values gets optimized away
-
- Member
- Posts: 5805
- Joined: Mon Mar 25, 2013 7:01 pm
-
- Posts: 5
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: Instant general protection fault error code 1816
Fixed this one but even after adding volatile to the declaration it still doesnt work and it doesnt look like its getting optimized away? (i updated the code on github)Octocontrabass wrote: ↑Wed May 28, 2025 7:48 pmYour exception handler needs to halt the CPU instead of returning. You can't return from an exception handler unless you do something to handle the exception!
Re: Instant general protection fault error code 1816
At the risk of giving the same boring answer as always, have you tried running your code under gdb with appropriate breakpoints/single-stepping? It should then be obvious exactly where the gpf is occurring and the machine state at that time. Then you just have to work out why that causes the gpf - which shouldn't be rocket science.
Debuggers are really useful tools - use them.
Debuggers are really useful tools - use them.
-
- Posts: 5
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: Instant general protection fault error code 1816
I tried but i dont know what to do if someone could help me or do it for me that would be amazing 

Re: Instant general protection fault error code 1816
This wiki article: https://wiki.osdev.org/QEMU#GDB-Stub tells you how to use gdb with qemu. The gdb user manual ( https://sourceware.org/gdb/current/onlinedocs/gdb.html/ ) explains how to use gdb.
It's a very useful tool and it's a good chance to learn it on a simple example. It's far better to learn how to solve your own problems rather than asking others to solve them for you. People here will spoon-feed you the answer, but - IMO - that way you don't learn to think for yourself.
It's a very useful tool and it's a good chance to learn it on a simple example. It's far better to learn how to solve your own problems rather than asking others to solve them for you. People here will spoon-feed you the answer, but - IMO - that way you don't learn to think for yourself.
-
- Member
- Posts: 5805
- Joined: Mon Mar 25, 2013 7:01 pm
-
- Posts: 5
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: Instant general protection fault error code 1816
No now its Exception 13 general protection fault (err code: 258)
-
- Member
- Posts: 5805
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Instant general protection fault error code 1816
That error code indicates a problem with the IDT entry for interrupt 0x20. Did you perhaps leave some IRQs unmasked when you initialized the interrupt controllers? All IRQs should be masked until you're ready to handle them.
-
- Posts: 5
- Joined: Wed May 28, 2025 8:20 am
- GitHub: https://github.com/Zeviraty
Re: Instant general protection fault error code 1816
Thanks!!!
i fixed it!!!


