A
kernel panic is an action taken by an
operating systemAn operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...
upon detecting an internal
fatal errorFatal System Error is a nonfiction work written by Joseph Menn that exposes a story of espionage that penetrates the network of international mobsters and hackers who use the Internet to extort money from businesses, steal from tens of millions of consumers, and attack government networks.Its main...
from which it cannot safely recover. The term is largely specific to
UnixUnix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
and
Unix-likeA Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
systems; for
Microsoft WindowsMicrosoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
operating systems the equivalent term is "
Bug checkFatal System Error is a nonfiction work written by Joseph Menn that exposes a story of espionage that penetrates the network of international mobsters and hackers who use the Internet to extort money from businesses, steal from tens of millions of consumers, and attack government networks.Its main...
" (or,
colloquiallyA colloquialism is a word or phrase that is common in everyday, unconstrained conversation rather than in formal speech, academic writing, or paralinguistics. Dictionaries often display colloquial words and phrases with the abbreviation colloq. as an identifier...
, "
Blue Screen of DeathTo forse a BSOD Open regedit.exe,Then search: HKLM\SYSTEM\CurrentControlSet\services\i8042prt\ParametersThen make a new DWORD called "CrashOnCtrlScroll" And set the value to 1....
").
The kernel routines that handle panics (known as
panic) in
AT&TAT&T Inc. is an American multinational telecommunications corporation headquartered in Whitacre Tower, Dallas, Texas, United States. It is the largest provider of mobile telephony and fixed telephony in the United States, and is also a provider of broadband and subscription television services...
-derived and
BSDBerkeley Software Distribution is a Unix operating system derivative developed and distributed by the Computer Systems Research Group of the University of California, Berkeley, from 1977 to 1995...
Unix source code) are generally designed to output an
error messageAn error message is information displayed when an unexpected condition occurs, usually on a computer or other device. On modern operating systems with graphical user interfaces, error messages are often displayed using dialog boxes...
to the
consoleThe system console, root console or simply console is the text entry and display device for system administration messages, particularly those from the BIOS or boot loader, the kernel, from the init system and from the system logger...
, dump an image of kernel memory to disk for post-mortem debugging and then either wait for the system to be manually rebooted, or initiate an automatic reboot. The information provided is of highly technical nature and aims to assist a
system administratorA system administrator, IT systems administrator, systems administrator, or sysadmin is a person employed to maintain and operate a computer system and/or network...
or
software developerA software developer is a person concerned with facets of the software development process. Their work includes researching, designing, developing, and testing software. A software developer may take part in design, computer programming, or software project management...
in diagnosing the problem.
History
The
UnixUnix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
kernel maintains internal consistency and runtime correctness with
assertionsIn computer programming, an assertion is a predicate placed in a program to indicate that the developer thinks that the predicate is always true at that place.For example, the following code contains two assertions:...
as fault detection mechanism. The basic assumption is that the hardware and the software should perform correctly and a failure of an assertion results a
panic, i.e. a voluntary halt to all system activity. The kernel panic was introduced in an early version of Unix and demonstrated a major difference between the design philosophies of Unix and its predecessor
MulticsMultics was an influential early time-sharing operating system. The project was started in 1964 in Cambridge, Massachusetts...
. Multics developer
Tom van Vleck-Life and work:He worked on CTSS at MIT, and co-authored its first email program.In 1965, he joined Project Mac, which is the origin of the MIT Computer Science and Artificial Intelligence Laboratory., Chiou, Stefanie; et. al...
recalls a discussion of this change with Unix developer
Dennis RitchieDennis MacAlistair Ritchie , was an American computer scientist who "helped shape the digital era." He created the C programming language and, with long-time colleague Ken Thompson, the UNIX operating system...
:
The original
panic function was essentially unchanged from Fifth Edition UNIX to the
VAXVAX was an instruction set architecture developed by Digital Equipment Corporation in the mid-1970s. A 32-bit complex instruction set computer ISA, it was designed to extend or replace DEC's various Programmed Data Processor ISAs...
-based UNIX 32V and output only an error message with no other information, then dropped the system into an endless idle loop.
Source code of
panic function in UNIX V6:
/*
* In case console is off,
* panicstr contains argument to last
* call to panic.
*/
char *panicstr;
/*
* Panic is called on unresolvable
* fatal errors.
* It syncs, prints "panic: mesg" and
* then loops.
*/
panic(s)
char *s;
{
panicstr = s;
update;
printf("panic: %s\n", s);
for
idle;
}
As the Unix
codebaseThe term codebase, or code base, is used in software development to mean the whole collection of source code used to build a particular application or component. Typically, the codebase includes only human-written source code files, and not, e.g., source code files generated by other tools or...
was enhanced, the
panic function was also enhanced to dump various forms of debugging information to the console.
Causes
A panic may occur as a result of a hardware failure or a bug in the operating system. In many cases, the operating system could continue operation after an error has occurred. However, the system is in an unstable state and rather than risking security breaches and data corruption, the operating system stops to prevent further damage and facilitate diagnosis of the error.
After recompiling a kernel binary image from
source codeIn computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
, a kernel panic during
bootingIn computing, booting is a process that begins when a user turns on a computer system and prepares the computer to perform its normal operations. On modern computers, this typically involves loading and starting an operating system. The boot sequence is the initial set of operations that the...
the resulting kernel is a common and annoying problem if the kernel was not configured, compiled or installed correctly. Add-on
hardwareHardware is a general term for equipment such as keys, locks, hinges, latches, handles, wire, chains, plumbing supplies, tools, utensils, cutlery and machine parts. Household hardware is typically sold in hardware stores....
or malfunctioning
RAM-Animals:*Ram, an uncastrated male sheep*Ram cichlid, a species of freshwater fish endemic to Colombia and Venezuela-Military:*Battering ram*Ramming, a military tactic in which one vehicle runs into another...
could also be a source of fatal kernel errors during start up, due to incompatibility with the OS or a missing
device driverIn computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....
. A kernel may also die with panic message if it is unable to locate a root file system. During final stages of kernel userspace initialization, a panic is triggered if the spawning of
initinit is a program for Unix-based computer operating systems that spawns all other processes. It runs as a daemon and typically has PID 1. The boot loader starts the kernel and the kernel starts init...
fails, since the system becomes unusable.
The following is an implementation of the Linux kernel final initialization in
init_post:
static noinline int init_post(void)
{
...
/*
* We try each of these until one succeeds.
*
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/
if (execute_command) {
run_init_process(execute_command);
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults...\n", execute_command);
}
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");
panic("No init found. Try passing init= option to kernel. "
"See Linux Documentation/init.txt for guidance.");
}
Linux
Kernel panics appear in
LinuxLinux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...
like other
Unix-likeA Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
systems, but can also generate another kind of error condition, known as a
kernel oopsAn oops is a deviation from correct behavior of the Linux kernel which produces a certain error log. The better-known kernel panic condition results from many kinds of oops, but others may allow continued operation with compromised reliability...
. In this case the kernel normally continues to run after
killingIn computing, kill is a command that is used in several popular operating systems to send signals to running processes, for example to request the termination of this process.-Unix and Unix-like:...
the offending
processIn computing, a process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system , a process may be made up of multiple threads of execution that execute instructions concurrently.A computer program is a...
. As an oops could cause some subsystems or resources to become unavailable, they can later lead to a full kernel panic.
Mac OS X
When a kernel panic occurs in Mac OS X, the computer displays a multilingual message informing the user that they need to reboot the system. The format varies from version to version:
- 10.0, 10.1: The system prints text detailing the error on-screen and then the system becomes unresponsive.
- 10.2: Similar to the current versions of the kernel panic except the text is more spaced out and the background is white.
- 10.3 - 10.5: The background is now black, but with the same language translations and the same text as version 10.2.
- 10.6 - 10.7: The text is different and now includes a Spanish translation.
In all versions above 10.2 the text is in superimposed on a
standby symbolA power symbol is a symbol indicating that a control activates or deactivates a particular device. It incorporates line and circle figures, with the arrangement informed by the function of the control...
and is not full screen. Debugging information is saved in NVRAM and written to a log file on reboot.