[英]Linux Kernel Programming: "Unable to handle kernel NULL pointer dereference"
I'm writing a Linux module and getting:我正在编写一个 Linux 模块并得到:
Unable to handle kernel NULL pointer dereference
What does it mean?这是什么意思?
Sounds like a pointer which currently has the NULL value (zero) is being dereferenced.听起来像当前具有 NULL 值(零)的指针正在被取消引用。 Assign an address to the pointer before dereferencing it.
在取消引用之前为指针分配一个地址。
eg例如
int x = 5;
int * x_ptr = NULL;
x_ptr = &x; // this line may be missing in your code
*x_ptr += 5; //can't dereference x_ptr here if x_ptr is still NULL
The kernel tries to read from address 0
, which your kernel apparently treats specially (good thing!).内核尝试从地址
0
读取,您的内核显然对其进行了特殊处理(好事!)。 As the kernel has no way to just kill itself like we know from user mode applications (those would have received a Segmentation Fault ), this error is fatal.由于内核无法像我们从用户模式应用程序中知道的那样自行杀死自己(那些会收到分段错误),所以这个错误是致命的。 It will have probably panic'ed and displayed that message to you.
它可能会惊慌失措并向您显示该消息。
http://en.wikipedia.org/wiki/Null_pointer#The_null_pointer http://en.wikipedia.org/wiki/Null_pointer#The_null_pointer
It means the kernel tried to deference a null pointer.这意味着内核试图遵从空指针。 This generates a page fault which can't be handled in the kernel- if it's running a user task (but in kernel space), it generally makes an "Oops" which (uncleanly) kills the current task and may leak kernel resources.
这会产生一个无法在内核中处理的页面错误——如果它正在运行一个用户任务(但在内核空间中),它通常会产生一个“Oops”,它(不干净地)杀死当前任务并可能泄漏内核资源。 If it's in some other context, eg an interrupt, it generally causes a kernel panic.
如果是在其他上下文中,例如中断,则通常会导致内核崩溃。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.