How to understand, analyze and debug a Linux kernel panic?

How to understand, analyze and debug a Linux kernel panic?

The bdi_register+0xec/0x150 is the symbol + the offset/length there’s more information about that in Understanding a Kernel Oops and how you can debug a kernel oops. Also there’s this excellent tutorial on Debugging the Kernel

What happens when you have a kernel panic?

In this case, the kernel normally continues to run after killing the offending process. As an oops could cause some subsystems or resources to become unavailable, they can later lead to a full kernel panic. In Linux kernel, a kernel panic causes keyboard LEDs to blink as a visual indication of a critical condition.

When to panic in a Unix operating system?

For example, many Unix operating systems panic if the init process, which runs in user space, terminates. The Unix kernel maintains internal consistency and runtime correctness with assertions as the fault detection mechanism.

How does the Unix kernel maintain internal consistency?

The Unix kernel maintains internal consistency and runtime correctness with assertions as the fault detection mechanism. The basic assumption is that the hardware and the software should perform correctly and a failure of an assertion results in a panic, i.e. a voluntary halt to all system activity.

What happens when the Linux kernel detects an oops?

Upon detecting an oops the Linux kernel kills the offending process, prints information that can help debug the problem and continues execution but with limited reliability. Lets consider the following Linux kernel module: Notice that ”do_oops” function tries to write at an invalid memory address.

Where to find unwind backtrace in Linux kernel?

Go to unwind_backtrace+0x0/0xf8, i.e. search for the address of unwind_backtrace + the offset. Finally, you have located the problematic part in your source code.

Which is an example of a kernel panic?

A kernel panic is a special type of oops where the kernel cannot continue execution. For example if the function do_oops from above was called in the interrupt context, the kernel wouldn’t know how to kill and it will decide that it is better to crash the kernel and stop execution.