Page 2 of 2

Re: IDT & Optimization

Posted: Sun Apr 20, 2014 8:48 am
by hometue
The bad luck number?? Does that mean the system detected bad luck?? (Sorry, just felt like making that distasteful joke, don't mind me)

Re: IDT & Optimization

Posted: Sun Apr 20, 2014 9:12 am
by inixsoftware
So I got a Global Protection Fault. What would cause that to happen?
Would an invalid IDT trigger it?

Re: IDT & Optimization

Posted: Sun Apr 20, 2014 9:58 am
by Nable
inixsoftware wrote:So I got a Global Protection Fault. What would cause that to happen?
Would an invalid IDT trigger it?
Look attentively, Bochs tells you about invalid IDT entry and even says what he finds invalid:

Code: Select all

00128266044e[CPU0 ] interrupt(): gate.type(9) != {5,6,7,14,15}
00128266044e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00128266044e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
Some above lines may be also important but you should have noticed at least these ones.

Re: IDT & Optimization

Posted: Sun Apr 20, 2014 10:13 am
by inixsoftware
OK, I get that. However, how did an -O3 optimization cause this issue, while -O2 doesn't. That is my question.

Re: IDT & Optimization

Posted: Sun Apr 20, 2014 11:30 am
by Nable
inixsoftware wrote:OK, I get that. However, how did an -O3 optimization cause this issue, while -O2 doesn't. That is my question.
Try reading Brendan's and Sortie's answers once again, you can find some possible answers to "how" question there.

I can add an idea about debugging: put a breakpoint on 'idt_set_gate' and examine IDT with (AFAIR) 'info idt' command of Bochs debugger after each return from this function (comparing results with parameters that were passed to function. If this procedure doesn't help, then it's possible that you enable interrupts too early or smth like that.