Page 1 of 1

Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 10:13 am
by rizor
Hi,

I have a big problem with my kernel.
The Kernel works correctly, if I use the kernel with the GDB in the single-step mode.
The Problem is, that the kernel crashs with a double fault.
The CPU-dump of the exception-handler is invalid. The error-code of the interrupt is the EIP of the last instruction before the exception.
If I call an interrupt in the single-step mode everything is fine and the dump is correct.
I checked my IDT and GDT ant they are correct.

I have no idea how to find the error.
Do you have any ideas?

I checked QEMU and Bochs and I can find the double fault in the logfiles.

Thank you.

rizor

Edit: I forgot to say, that the EIP in the dump is the interrupt code (only without single-step)

Re: Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 12:15 pm
by Combuster
Bochs generates a complete dump on a panic, and with the internal debugger enabled you can also probe the entire system state without ever affecting the actual simulation.

That said, if you actually see EIP being the same as the error code, it probably means you corrupted the stack and used the error code as the return address - you might possibly observe that CS/SS/EFLAGS/ESP are not right as well. Make sure to remove any error code pushed by an exception.

Re: Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 12:29 pm
by rizor
I don't know what you mean. It is now Bochs panic. My kernel catches the exception and stops the system. I tried to check it without an IDT, but Bochs resetted the CPU and it was impossible to see something helpful

Re: Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 12:43 pm
by Combuster
Please read the manual before claiming something is impossible - if something seems impossible it only means you didn't spend enough effort.

Re: Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 1:08 pm
by rizor
I can't read the CPU dump of the interrupt. Bochs sais, that dump_cpu is invalid. The command registers does not help.

How can I print the dump after the exception?

Re: Double Fault without the single-steop mode

Posted: Wed Mar 02, 2011 1:39 pm
by Combuster
dump_cpu works as expected, nor do I need it as bochs automatically dumps the state to the log on a reset. I even tested it for you by injecting a software interrupt in a bad place and watching the shell:

Code: Select all

00158805518e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00158805518e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00158805518e[CPU0 ] interrupt(): gate descriptor is not valid sys seg
00158805518i[CPU0 ] protected mode
00158805518i[CPU0 ] CS.d_b = 32 bit
00158805518i[CPU0 ] SS.d_b = 32 bit
00158805518i[CPU0 ] | EAX=00000008  EBX=0001055b  ECX=00000000  EDX=00400000
00158805518i[CPU0 ] | ESP=0000fffe  EBP=00000000  ESI=00030000  EDI=00401000
00158805518i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00158805518i[CPU0 ] | SEG selector     base    limit G D
00158805518i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00158805518i[CPU0 ] |  CS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] |  DS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] |  SS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] |  ES:0008( 0001| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] |  FS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] |  GS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00158805518i[CPU0 ] | EIP=00080001 (00080001)
00158805518i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00158805518i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00158805518i[CPU0 ] >> int3  : CC
00158805518e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
You need to be more specific: what exactly do you try, what exactly do you expect, what exactly do you see? The only problem I can see is still the one between the keyboard and chair.