{"id":51669,"date":"2024-12-03T08:09:49","date_gmt":"2024-12-03T00:09:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/51669\/"},"modified":"2024-12-03T08:09:49","modified_gmt":"2024-12-03T00:09:49","slug":"%e4%bb%80%e4%b9%88%e6%98%aflinux-oops%ef%bc%9f%e8%a7%a3%e6%9e%90%e9%94%99%e8%af%af%e4%bf%a1%e6%81%af-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/51669\/","title":{"rendered":"\u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f<\/h1>\n<p>Linux Oops\u662f\u5185\u6838\u5728\u9047\u5230\u4e25\u91cd\u9519\u8bef\u65f6\u8f93\u51fa\u7684\u4fe1\u606f\uff0c\u7c7b\u4f3c\u4e8eWindows\u7684\u84dd\u5c4f\u9519\u8bef\u3002\u5b83\u63d0\u4f9b\u4e86\u5173\u952e\u4fe1\u606f\uff0c\u7528\u4e8e\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002\u5206\u6790Oops\u4fe1\u606f\u5bf9\u4e8e\u786e\u4fdd\u7cfb\u7edf\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h1>\u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f\uff0c\u9700\u8981\u5177\u4f53\u4ee3\u7801\u793a\u4f8b<\/h1>\n<h2>\u7b80\u4ecb<\/h2>\n<p>Linux Oops\u662f\u6307Linux\u5185\u6838\u5728\u53d1\u751f\u4e25\u91cd\u9519\u8bef\u65f6\u8f93\u51fa\u7684\u4e00\u79cd\u9519\u8bef\u4fe1\u606f\uff0c\u7c7b\u4f3c\u4e8eWindows\u7cfb\u7edf\u7684\u84dd\u5c4f\u9519\u8bef\u3002\u5f53Linux\u5185\u6838\u9047\u5230\u65e0\u6cd5\u5904\u7406\u7684\u4e25\u91cd\u9519\u8bef\u65f6\uff0c\u4f1a\u505c\u6b62\u8fd0\u884c\u5e76\u8f93\u51fa\u4e00\u6bb5\u79f0\u4e3aOops\u4fe1\u606f\u7684\u9519\u8bef\u65e5\u5fd7\uff0c\u901a\u8fc7\u5206\u6790\u8fd9\u4e9b\u4fe1\u606f\u53ef\u4ee5\u5b9a\u4f4d\u95ee\u9898\u5e76\u8fdb\u884c\u8c03\u8bd5\u3002<\/p>\n<h2>Oops\u4fe1\u606f\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Linux Oops\u4fe1\u606f\u793a\u4f8b\uff1a<\/p>\n<pre>BUG: unable to handle kernel NULL pointer dereference at 0000000000000008\nIP: [&lt;ffffffffa01f9f1a&gt;] some_function+0x1a\/0x40 [module_name]\nPGD 7e0b067 PUD 7e0c067 PMD 0\nOops: 0000 [#1] SMP\nModules linked in: module_name\nCPU: 0 PID: 1 Comm: init Not tainted 4.19.0-16-amd64 #1 Debian 4.19.181-1\nHardware name: VirtualBox VirtualBox, BIOS VirtualBox 12\/01\/2006\nRIP: 0010:some_function+0x1a\/0x40 [module_name]\nRSP: 0018:ffffb3db003f3d8f\nRAX: 0000000000000000 RBX: ffffabc656688000 RCX: 0000000000000000\nRDX: 0000000000000000 RSI: ffffabc6566880f8 RDI: 0000000000000000\nRBP: ffffb3db003f3d8f R08: 0000000000000000 R09: 0000000000000000\nR10: 0000000000000024 R11: 0000000000000003 R12: ffffabc6566880f8\nR13: ffffabc6fad9d008 R14: 0000000000000000 R15: ffffabc656688000\nFS: 0000000000000000(0000) GS:ffffabc6fac20000(0000) knlGS:0000000000000000\nCS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033\nCR2: 0000000000000008 CR3: 0000001f23df6000 CR4: 00000000000706f0\nCall Trace:\nanother_function+0x2b\/0x60 [module_name]\ninit+0x1f\/0x30<\/pre>\n<h2>\u89e3\u6790\u9519\u8bef\u4fe1\u606f<\/h2>\n<ol>\n<li><code>BUG<\/code>\uff1a\u6307\u793a\u53d1\u751f\u4e86\u4e00\u4e2a\u9519\u8bef\u3002<\/li>\n<li><code>unable to handle kernel NULL pointer dereference at 0000000000000008<\/code>\uff1a\u6307\u793a\u5185\u6838\u65e0\u6cd5\u5904\u7406\u4e00\u4e2a\u7a7a\u6307\u9488\u89e3\u5f15\u7528\u9519\u8bef\u3002<\/li>\n<li><code>IP<\/code>\uff1a\u6307\u51fa\u53d1\u751f\u9519\u8bef\u7684\u6307\u4ee4\u5730\u5740\u3002<\/li>\n<li><code>PGD PUD PMD<\/code>\uff1a\u63cf\u8ff0\u4e86\u51fa\u9519\u65f6\u7684\u9875\u8868\u60c5\u51b5\u3002<\/li>\n<li><code>Oops<\/code>\uff1a\u6307\u51fa\u8fd9\u662f\u4e00\u4e2aOops\u4fe1\u606f\u3002<\/li>\n<li><code>Modules linked in<\/code>\uff1a\u5217\u51fa\u4e86\u52a0\u8f7d\u7684\u6a21\u5757\u3002<\/li>\n<li><code>CPU<\/code>\uff1a\u6307\u51fa\u53d1\u751f\u9519\u8bef\u7684CPU\u7f16\u53f7\u3001\u8fdb\u7a0bID\u548c\u8fdb\u7a0b\u540d\u3002<\/li>\n<li><code>RIP<\/code>\uff1a\u6307\u793a\u5f15\u53d1\u9519\u8bef\u7684\u6307\u4ee4\u5730\u5740\u548c\u6a21\u5757\u3002<\/li>\n<li>\u5bc4\u5b58\u5668\u4fe1\u606f\uff1a\u63cf\u8ff0\u4e86\u4e00\u4e9bCPU\u5bc4\u5b58\u5668\u7684\u503c\u3002<\/li>\n<li><code>Call Trace<\/code>\uff1a\u663e\u793a\u4e86\u9519\u8bef\u53d1\u751f\u65f6\u7684\u51fd\u6570\u8c03\u7528\u6808\u3002<\/li>\n<\/ol>\n<h2>\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684C\u4ee3\u7801\u793a\u4f8b\uff0c\u6a21\u62df\u4e86\u5f15\u53d1Oops\u7684\u7a7a\u6307\u9488\u89e3\u5f15\u7528\u9519\u8bef\u60c5\u51b5\uff1a<\/p>\n<pre>#include &lt;linux\/module.h&gt;\n#include &lt;linux\/init.h&gt;\n\nstatic int *ptr = NULL;\n\nstatic int __init oops_example_init(void)\n{\n    int value;\n    \n    value = *ptr;  \/\/ \u5f15\u53d1\u7a7a\u6307\u9488\u89e3\u5f15\u7528\u9519\u8bef\n    \n    return 0;\n}\n\nstatic void __exit oops_example_exit(void)\n{\n    printk(KERN_INFO \"Exiting Oops Example Module\n\");\n}\n\nmodule_init(oops_example_init);\nmodule_exit(oops_example_exit);\n\nMODULE_LICENSE(\"GPL\");\nMODULE_AUTHOR(\"Author\");<\/pre>\n<h2>\u7ed3\u8bba<\/h2>\n<p>Linux Oops\u4fe1\u606f\u63d0\u4f9b\u4e86\u6709\u5173\u5185\u6838\u53d1\u751f\u4e25\u91cd\u9519\u8bef\u7684\u5173\u952e\u4fe1\u606f\uff0c\u901a\u8fc7\u89e3\u6790Oops\u4fe1\u606f\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u53ef\u4ee5\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002\u5728\u5f00\u53d1\u6216\u8c03\u8bd5Linux\u5185\u6838\u6a21\u5757\u65f6\uff0c\u53ca\u65f6\u5904\u7406Oops\u4fe1\u606f\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u4ee5\u4fdd\u8bc1\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8eLinux,\u89e3\u6790,oops\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5c55\u671bGolang\u5728\u64cd\u4f5c\u7cfb\u7edf\u9886\u57df\u7684\u53d1\u5c55\u524d\u666f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f Linux Oops\u662f\u5185\u6838\u5728\u9047\u5230\u4e25\u91cd\u9519\u8bef\u65f6\u8f93\u51fa\u7684\u4fe1\u606f\uff0c\u7c7b\u4f3c\u4e8eWindows\u7684\u84dd\u5c4f\u9519\u8bef\u3002\u5b83\u63d0\u4f9b\u4e86\u5173\u952e\u4fe1\u606f\uff0c\u7528\u4e8e\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002\u5206\u6790Oops\u4fe1\u606f\u5bf9\u4e8e\u786e\u4fdd\u7cfb\u7edf\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u81f3\u5173\u91cd\u8981\u3002 \u4ec0\u4e48\u662fLinux Oops\uff1f\u89e3\u6790\u9519\u8bef\u4fe1\u606f\uff0c\u9700\u8981\u5177\u4f53\u4ee3\u7801\u793a\u4f8b \u7b80\u4ecb Linux Oops\u662f\u6307Linux\u5185\u6838\u5728\u53d1\u751f\u4e25\u91cd\u9519\u8bef\u65f6\u8f93\u51fa\u7684\u4e00\u79cd\u9519\u8bef\u4fe1\u606f\uff0c\u7c7b\u4f3c\u4e8eWindows\u7cfb\u7edf\u7684\u84dd\u5c4f\u9519\u8bef\u3002\u5f53Linux\u5185\u6838\u9047\u5230\u65e0\u6cd5\u5904\u7406\u7684\u4e25\u91cd\u9519\u8bef\u65f6\uff0c\u4f1a\u505c\u6b62\u8fd0\u884c\u5e76\u8f93\u51fa\u4e00\u6bb5\u79f0\u4e3aOops\u4fe1\u606f\u7684\u9519\u8bef\u65e5\u5fd7\uff0c\u901a\u8fc7\u5206\u6790\u8fd9\u4e9b\u4fe1\u606f\u53ef\u4ee5\u5b9a\u4f4d\u95ee\u9898\u5e76\u8fdb\u884c\u8c03\u8bd5\u3002 Oops\u4fe1\u606f\u793a\u4f8b \u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Linux Oops\u4fe1\u606f\u793a\u4f8b\uff1a BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: [&lt;ffffffffa01f9f1a&gt;] some_function+0x1a\/0x40 [module_name] PGD 7e0b067 PUD 7e0c067 PMD 0 Oops: 0000 [#1] SMP Modules linked in: module_name CPU: 0 PID: 1 Comm: init Not tainted 4.19.0-16-amd64 #1 Debian 4.19.181-1 Hardware name: VirtualBox [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-51669","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=51669"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/51669\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=51669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=51669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=51669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}