dslreports logo
 
    All Forums Hot Topics Gallery
spc
uniqs
33

SirSteve
Premium Member
join:2003-11-28
Woodbury, CT

SirSteve to Johnny34

Premium Member

to Johnny34

Re: Can someone explain a Kernel Panic on the Mac?

Thanks for all the replies.

I have to say, in the PC world when using Windows 98/Me the Blue Screen of Death was known to most everyone. However, with a fully patched XP/SP2 system, I have never seen the BSD or experienced a crash that required a restart.

bobrk
You kids get offa my lawn
Premium Member
join:2000-02-02
San Jose, CA
·SONIC

bobrk

Premium Member

I must say that I've never seen a BSD on my various XP work boxen, but they do get to a point where they just don't work right any more, lose speed, and beome unresonsive. I had one today where Outlook first started acting up and then wouldn't start again. I just rebooted to fix it.

I've been running Mac OS X on a Cube since the beta days and now on both a Cube and a G5, and I don't think I've ever seen a KP. Lameass programs (like Safari) crash all the time, but the box doesn't.

BrushedTooth
Remember To Shop Smart Shop S Mart
join:2001-02-12
Westerville, OH

BrushedTooth

Member

Didn't microsoft disable the bsod and basically does a force reboot?

TheBobby
Premium Member
join:2003-07-27
UK

TheBobby

Premium Member

said by BrushedTooth:

Didn't microsoft disable the bsod and basically does a force reboot?
By default it does, but you can set it to display the BSOD and not reboot.

Johnny34
Fed Up. Bye.
Premium Member
join:2001-06-27
Atlanta, GA

Johnny34

Premium Member

said by TheBobby:

said by BrushedTooth:

Didn't microsoft disable the bsod and basically does a force reboot?
By default it does, but you can set it to display the BSOD and not reboot.
Theoretically it is better for the kernel to just stop, as the system is in an unknown state at this point and there is no guarantee that the restart code will work, or that it is even intact. Since the exception occurred while kernel code was running, it may have written to any number of unknown locations in the kernel, even overwriting valid kernel code, before it finally hit a location that was an invalid instruction and bombed. This is why Mac OS X writes the kernel panic data to VRAM and reads it back into a disk file after reboot, as there is no guarantee that the disk driver code is in a workable state after a panic.

Let's say that the original bug was a branch instruction that was supposed to branch to location 4000 in the kernel, but somehow it was set to branch to location 5000 (this branch was supposed to be for a rare condition and the QA testing never actually caused this branch to be tested). So what happens when it jumps to location 5000 is it encounters valid instructions for storing the contents of the registers at whatever location is in register 15. The problem is that register 15 does not contain the proper address, as the program did not get to location 5000 from the place it was expected to - it got there from the bad branch instruction. So it proceeds to store the 32 registers in the 128 bytes starting at the location in register 15, which just happens to point to 8 bytes ahead of where the program is executing now. Unfortunately for the kernel, the last 124 bytes that it stores overwrites the beginning of the subroutine that writes a buffer of data to a track and sector on the hard drive. That code is now replaced with random data. After the store, the program proceeds to the next instruction which is a load, which proceeds fine, and then it executes the 4 bytes that it just erroneously stored in the location 8 bytes ahead of where it was 2 instructions ago. That 4 bytes happens to not be a valid opcode for the instruction set, and the CPU raises an exception, sending the program to the "handle interrupt" location. That is where it discovers that it was itself that caused the exception and it calls a panic. Now if it tried at that point to save something to disk, it would be trying to execute the garbage that it stored there before, and the CPU would again raise an exception, and the kernel would again call a panic, and try to write to disk again, and so forth forever.