{"id":468,"date":"2021-04-24T00:19:28","date_gmt":"2021-04-23T16:19:28","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=468"},"modified":"2024-05-05T14:19:47","modified_gmt":"2024-05-05T06:19:47","slug":"%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=468","title":{"rendered":"\u5185\u5b58\u7ba1\u7406"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title ez-toc-toggle\" style=\"cursor:pointer\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E6%95%B0%E6%8D%AE%E5%AD%98%E6%94%BE\" >\u6570\u636e\u5b58\u653e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E5%86%85%E5%AD%98%E5%88%86%E9%85%8D\" >\u5185\u5b58\u5206\u914d<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E9%87%8E%E6%8C%87%E9%92%88\" >\u91ce\u6307\u9488<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E5%B8%B8%E8%A7%81%E5%86%85%E5%AD%98%E9%94%99%E8%AF%AF\" >\u5e38\u89c1\u5185\u5b58\u9519\u8bef<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E6%AE%B5%E9%94%99%E8%AF%AF%E5%8F%8A%E8%B0%83%E8%AF%95%E6%96%B9%E6%B3%95\" >\u6bb5\u9519\u8bef\u53ca\u8c03\u8bd5\u65b9\u6cd5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.iyatt.com\/?p=468\/#%E5%88%86%E6%9E%90_core_%E6%96%87%E4%BB%B6\" >\u5206\u6790 core \u6587\u4ef6<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%95%B0%E6%8D%AE%E5%AD%98%E6%94%BE\"><\/span>\u6570\u636e\u5b58\u653e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"801\" height=\"807\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-222729-1.png\" alt=\"\" class=\"wp-image-469 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-222729-1.png 801w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-222729-1-298x300.png 298w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-222729-1-150x150.png 150w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-222729-1-768x774.png 768w\" data-sizes=\"(max-width: 801px) 100vw, 801px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 801px; --smush-placeholder-aspect-ratio: 801\/807;\" \/><\/figure>\n\n\n\n<p>64\u4f4d\u5206\u5e03\u8981\u590d\u6742\u4e9b\uff0c\u5bfb\u5740\u7a7a\u95f4\u5e76\u4e0d\u662f64\u4f4d\uff0c\u4f7f\u7528\u5176\u4e2d\u4e00\u90e8\u5206\uff0c\u5176\u5b83\u4f5c\u4e3a\u6269\u5c55\uff0c\u5206\u5e03\u770b\u60c5\u51b5\u800c\u5b9a\u3002\u7406\u89e3\u5927\u4f53\u5206\u5e03\u5c31\u770b32\u4f4d\u7684\u66f4\u597d\u3002\u5bf9\u4e8e\u5185\u5b58\u7ba1\u7406\u8fd9\u90e8\u5206\u53ea\u662f\u8c08\u5176\u4e2d\u7528\u6237\u533a\u7684\u4e00\u90e8\u5206\u3002<\/p>\n\n\n\n<p><strong>.bss\uff08\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\uff09<\/strong><\/p>\n\n\n\n<p>\u8be5\u6bb5\u7528\u6765\u5b58\u653e\u6ca1\u6709\u521d\u59cb\u5316\u548c\u521d\u59cb\u5316\u4e3a0\uff08\u5305\u62ec\u503c\u6539\u4e3a0\uff09\u7684\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"668\" height=\"489\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-230047-2.png\" alt=\"\" class=\"wp-image-470 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-230047-2.png 668w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-230047-2-300x220.png 300w\" data-sizes=\"(max-width: 668px) 100vw, 668px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 668px; --smush-placeholder-aspect-ratio: 668\/489;\" \/><\/figure>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\u5b9a\u4e49\u7684\u5168\u5c40\u53d8\u91cf\u5927\u5c0f\u4e3a 1024 x 1024 x 4 \/ (1024 x 1024) MB= 4 MB\uff0c\u4f46\u662f\u751f\u6210\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\u6587\u4ef6\u5927\u5c0f\u4ec5 17KB \uff0c\u4e5f\u8bf4\u660e bss \u4e0d\u5360\u7528\u6587\u4ef6\u7a7a\u95f4\uff0c\u53ea\u662f\u8fd0\u884c\u65f6\u5360\u7528\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p>\u8be5\u6bb5\u6570\u636e\u5728\u8fd0\u884c\u671f\u95f4\u5168\u7a0b\u5b58\u5728\u3002<\/p>\n\n\n\n<p><strong>.data \uff08\u521d\u59cb\u5316\u8fc7\u7684\u5168\u5c40\u53d8\u91cf\uff09<\/strong><\/p>\n\n\n\n<p>\u5b58\u653e\u521d\u59cb\u5316\u8fc7\u7684\u4e14\u503c\u4e0d\u4e3a0\u7684\u5168\u5c40\u53d8\u91cf\u6216\u8005\u9759\u6001\u53d8\u91cf\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"673\" height=\"498\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-232547-1.png\" alt=\"\" class=\"wp-image-471 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-232547-1.png 673w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-23-232547-1-300x222.png 300w\" data-sizes=\"(max-width: 673px) 100vw, 673px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 673px; --smush-placeholder-aspect-ratio: 673\/498;\" \/><\/figure>\n\n\n\n<p>\u800c\u6539\u4e3a\u521d\u59cb\u4e3a\u975e0\u503c\u540e\uff0c\u6587\u4ef6\u5c31\u53d8\u4e3a 4MB\u591a\u4e86\u3002\u8bf4\u660e data \u4f1a\u5360\u7528\u6587\u4ef6\u7a7a\u95f4\uff0c\u5f53\u7136\u8fd0\u884c\u65f6\u4e5f\u4f1a\u5360\u7528\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<p>\u8be5\u6bb5\u6570\u636e\u5728\u8fd0\u884c\u671f\u95f4\u5168\u7a0b\u5b58\u5728\u3002<\/p>\n\n\n\n<p><strong>.rodata (\u5e38\u91cf\u6570\u636e\uff09<\/strong><\/p>\n\n\n\n<p>\u8fd9\u4e2a\u6bb5\u5728\u4e0a\u9762\u5730\u5740\u7a7a\u95f4\u5206\u5e03\u56fe\u4e2d\u6ca1\u6709\u6807\u51fa\uff0c\u4e00\u822c\u5b83\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u52a0\u8f7d\uff0c\u548c text \u5408\u5e76\u5230\u540c\u4e00\u4e2a\u6bb5\u3002\u8be5\u6bb5\u4e3b\u8981\u5b58\u653e\u53ea\u8bfb\u6570\u636e\uff0c\u6bd4\u5982\u5b57\u7b26\u4e32\u5e38\u91cf\u4ee5\u53caconst\u4fee\u9970\u7684\u5168\u5c40\u53d8\u91cf\u3002<\/p>\n\n\n\n<p>\u00b7 \u5e38\u91cf\u4e0d\u4e00\u5b9a\u5c31\u5b58\u653e\u5728 rodata \u91cc\uff0c\u6709\u7684\u76f4\u63a5\u548c\u6307\u4ee4\u7f16\u7801\u5728\u4e00\u8d77\uff0c\u5b58\u653e\u5728 text\u3002<\/p>\n\n\n\n<p>\u00b7 \u5bf9\u4e8e\u5b57\u7b26\u4e32\u5e38\u91cf\uff0c\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u53bb\u9664\u91cd\u590d\u7684\u5b57\u7b26\u4e32\uff0c\u4fdd\u8bc1\u4e00\u4e2a\u5b57\u7b26\u4e32\u5728\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e2d\u53ea\u5b58\u5728\u4e00\u4efd\u590d\u5236\u3002<\/p>\n\n\n\n<p>\u00b7 rodata \u5728\u591a\u4e2a\u8fdb\u7a0b\u95f4\u662f\u5171\u4eab\u7684\uff0c\u8fd9\u6837\u53ef\u4ee5\u63d0\u9ad8\u8fd0\u884c\u7a7a\u95f4\u5229\u7528\u7387\u3002<\/p>\n\n\n\n<p>\u00b7 \u5728\u6709\u7684\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d\uff0crodata \u653e\u5728 ROM \uff08\u6216\u8005 NOR Flash\uff09\u91cc\uff0c\u8fd0\u884c\u65f6\u76f4\u63a5\u8bfb\u53d6\uff0c\u4e0d\u9700\u8981\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002\u5728\u5d4c\u5165\u5f0fLinux\u7cfb\u7edf\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4e00\u79cd\u53eb\u505a XIP \uff08\u5c31\u5730\u6267\u884c\uff09\u7684\u6280\u672f\uff0c\u76f4\u63a5\u8bfb\u53d6\uff0c\u800c\u65e0\u9700\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u3002<\/p>\n\n\n\n<p>\u00b7 \u5e38\u91cf\u662f\u4e0d\u80fd\u88ab\u4fee\u6539\u7684\uff0c\u4fee\u6539\u5e38\u91cf\u5728Linux\u4e0b\u4f1a\u51fa\u73b0\u6bb5\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u7531\u6b64\u53ef\u89c1\uff0c\u628a\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u6539\u53d8\u7684\u6570\u636e\u8bbe\u4e3a rodata \u662f\u6709\u597d\u5904\u7684\u3002\u5728\u591a\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u5171\u4eab\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u7a7a\u95f4\u5229\u7528\u7387\uff0c\u751a\u81f3\u4e0d\u5360\u7528\u5185\u5b58\u7a7a\u95f4\u3002\u540c\u65f6\u7531\u4e8e rodata \u5728\u53ea\u8bfb\u7684\u5185\u5b58\u4e5f\u9875\u9762 \uff08page\uff09\u4e2d\u662f\u53d7\u4fdd\u62a4\u7684\uff0c\u4efb\u4f55\u8bd5\u56fe\u5bf9\u5b83\u7684\u4fee\u6539\u90fd\u4f1a\u88ab\u5373\u65f6\u53d1\u73b0\uff0c\u8fd9\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u3002<\/p>\n\n\n\n<p><strong>.text (\u4ee3\u7801\uff09<\/strong><\/p>\n\n\n\n<p>\u8be5\u6bb5\u7528\u4e8e\u5b58\u653e\u4ee3\u7801\uff08\u5982\u51fd\u6570\uff09\u548c\u90e8\u5206\u6574\u6570\u5e38\u91cf\uff0c\u5b83\u4e0e rodata \u6bb5\u5f88\u76f8\u4f3c\uff0c\u4e3b\u8981\u4e0d\u540c\u5c31\u662f\u8fd9\u4e2a\u6bb5\u662f\u53ef\u4ee5\u6267\u884c\u7684\u3002<\/p>\n\n\n\n<p><strong>stack \uff08\u6808\uff09<\/strong><\/p>\n\n\n\n<p>\u6808\u7528\u4e8e\u5b58\u653e\u4e34\u65f6\u53d8\u91cf\u548c\u51fd\u6570\u53c2\u6570\u3002\u6808\u4f5c\u4e3a\u4e00\u79cd\u57fa\u672c\u6570\u636e\u7ed3\u6784\uff0c\u53ef\u4ee5\u7528\u6765\u5b9e\u73b0\u51fd\u6570\u7684\u8c03\u7528\uff0c\u8981\u5b9e\u73b0\u9012\u5f52\u64cd\u4f5c\uff0c\u4e0d\u7528\u6808\u4e0d\u662f\u4e0d\u53ef\u80fd\uff0c\u53ea\u662f\u627e\u4e0d\u51fa\u6bd4\u5b83\u66f4\u597d\u7684\u65b9\u5f0f\u3002\u5c3d\u7ba1\u5927\u591a\u6570\u7f16\u8bd1\u5668\u5728\u4f18\u5316\u65f6\uff0c\u4f1a\u628a\u5e38\u7528\u7684\u53c2\u6570\u6216\u8005\u5168\u5c40\u53d8\u91cf\u653e\u5165\u5bc4\u5b58\u5668\u4e2d\u3002\u4f46\u7528\u6808\u6765\u7ba1\u7406\u51fd\u6570\u8c03\u7528\u65f6\u7684\u4e34\u65f6\u53d8\u91cf\uff08\u5c40\u90e8\u53d8\u91cf\u548c\u53c2\u6570\uff09\u662f\u901a\u7528\u505a\u6cd5\uff0c\u524d\u8005\u53ea\u662f\u8f85\u52a9\u624b\u6bb5\uff0c\u4e14\u53ea\u5728\u5f53\u524d\u51fd\u6570\u4e2d\u4f7f\u7528\uff0c\u4e00\u65e6\u8c03\u7528\u4e0b\u4e00\u5c42\u51fd\u6570\uff0c\u8fd9\u4e9b\u503c\u4efb\u7136\u8981\u5b58\u5165\u6808\u624d\u884c\u3002<\/p>\n\n\n\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6808\u5411\u4e0b\u589e\u957f\uff0c\u6bcf\u5411\u6808\u4e2d PUSH \u4e00\u4e2a\u5143\u7d20\uff0c\u6808\u9876\u5c31\u5411\u4f4e\u5730\u5740\u6269\u5c55\uff0c\u6bcf\u4ece\u6808\u4e2d POP \u4e00\u4e2a\u5143\u7d20\uff0c\u6808\u9876\u5c31\u5411\u9ad8\u5730\u5740\u56de\u9000\u3002\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b58\u653e\u5728\u6808\u4e2d\u7684\u6570\u636e\u53ea\u5728\u5f53\u524d\u51fd\u6570\u548c\u4e0b\u4e00\u5c42\u51fd\u6570\u4e2d\u6709\u6548\uff0c\u4e00\u65e6\u51fd\u6570\u8fd4\u56de\uff0c\u8fd9\u4e9b\u6570\u636e\u4e5f\u88ab\u81ea\u52a8\u91ca\u653e\u4e86\uff0c\u7ee7\u7eed\u8bbf\u95ee\u8fd9\u4e9b\u53d8\u91cf\u662fUB\uff08\u672a\u5b9a\u4e49\u7684\u884c\u4e3a\uff0c\u540e\u540c\uff09\uff0c\u6211\u4eec\u5e94\u8be5\u907f\u5f00\u8fd9\u6837\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><strong>heap (\u5806\uff09<\/strong><\/p>\n\n\n\n<p>\u5806\u662f\u6700\u7075\u6d3b\u7684\u4e00\u79cd\u5185\u5b58\uff0c\u5b83\u7684\u751f\u547d\u5468\u671f\u5b8c\u5168\u7531\u4f7f\u7528\u8005\u63a7\u5236\u3002ISO C\u63d0\u4f9b\u4ee5\u4e0b\u51e0\u4e2a\u51fd\u6570\uff1a<\/p>\n\n\n\n<p>\u00b7 malloc\/calloc \u7528\u6765\u5206\u914d\u4e00\u5757\u6307\u5b9a\u5927\u5c0f\u7684\u5185\u5b58\u3002<\/p>\n\n\n\n<p>\u00b7 realloc \u7528\u6765\u8c03\u6574\/\u91cd\u65b0\u5206\u914d\u4e00\u5757\u5b58\u5728\u7684\u5185\u5b58\u3002<\/p>\n\n\n\n<p>\u00b7 free \u7528\u6765\u91ca\u653e\u5185\u5b58\u3002<\/p>\n\n\n\n<p>malloc\u548cfree\u8981\u914d\u5bf9\u4f7f\u7528\u3002\u5185\u5b58\u5206\u914d\u4e4b\u540e\u4e0d\u91ca\u653e\u79f0\u4e3a\u5185\u5b58\u6cc4\u6f0f\uff08Memory Leak\uff09\uff0c\u5185\u5b58\u6cc4\u6f0f\u591a\u4e86\u4f1a\u51fa\u73b0 <span style=\"color:#6000a3\" class=\"has-inline-color\">Out of memory<\/span> \u7684\u9519\u8bef\uff0c\u518d\u5206\u914d\u5185\u5b58\u5c31\u4f1a\u5931\u8d25\u3002\u5f53\u7136\u91ca\u653e\u65f6\u4e5f\u53ea\u80fd\u91ca\u653e\u81ea\u5df1\u5206\u914d\u7684\u5185\u5b58\uff0c\u91ca\u653e\u65e0\u6548\u7684\u5185\u5b58\u6216\u8005\u91cd\u590dfree\u90fd\u662f\u4e0d\u884c\u7684\uff0c\u4f1a\u9020\u6210\u7a0b\u5e8f\u5d29\u6e83\uff08crash\uff09\u3002\u5206\u914d\u591a\u5c11\u5185\u5b58\u5c31\u7528\u591a\u5c11\u5185\u5b58\uff0c\u4e0d\u7ba1\u662f\u8bfb\u8fd8\u662f\u5199\uff0c\u90fd\u53ea\u80fd\u5728\u81ea\u5df1\u5206\u914d\u7684\u5927\u5c0f\u8303\u56f4\u5185\uff0c\u8bfb\u591a\u4e86\u4f1a\u8bfb\u5230\u5783\u573e\u503c\uff0c\u5199\u591a\u4e86\u4f1a\u9020\u6210\u968f\u673a\u7834\u574f\uff0c\u8fd9\u79cd\u60c5\u51b5\u6211\u4eec\u79f0\u4e3a\u7f13\u51b2\u533a\u6ea2\u51fa\uff08Buffer Overflow\uff09\uff0c\u8fd9\u662f\u975e\u5e38\u4e25\u91cd\u7684\uff0c\u5927\u90e8\u5206\u5b89\u5168\u95ee\u9898\u90fd\u662f\u7531\u7f13\u51b2\u533a\u6ea2\u51fa\u5f15\u8d77\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"763\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-005114-1-1024x763.png\" alt=\"\" class=\"wp-image-475 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-005114-1-1024x763.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-005114-1-300x223.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-005114-1-768x572.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-005114-1.png 1038w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/763;\" \/><\/figure>\n\n\n\n<p>\u4e0a\u9762\u4ee3\u7801\u4e2d\u7533\u8bf7\u4e86\u4e24\u4e2aint\u5927\u5c0f\u7684\u5185\u5b58\uff08\u89c6\u4e3a\u6570\u7ec4\uff09\uff0c\u4f46\u662f\u6211\u5411\u5b83\u7684\u7b2c4\u4e2a\u4f4d\u7f6e\u5199\u5165\u4e86\u6570\u636e\uff0c\u5e76\u4e14\u4e5f\u6b63\u5e38\u8bfb\u53d6\u4e86\uff0c\u5168\u7136\u770b\u4f3c\u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u662f\u8bf4\u4e0d\u5b9a\u4e0b\u6b21\u54ea\u4e2a\u65f6\u5019\u5c31\u662f\u4e00\u4e2a\u8fd0\u884c\u9519\u8bef\uff08\u6f5c\u5728\u7684bug\uff09\u3002<\/p>\n\n\n\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u7a0b\u5e8f\u5341\u5206\u590d\u6742\uff0c\u624b\u52a8\u68c0\u67e5\u6709\u6ca1\u6709\u5185\u5b58\u6cc4\u6f0f\u6216\u8005\u7f13\u51b2\u533a\u6ea2\u51fa\u662f\u5f88\u56f0\u96be\u7684\uff0c\u4e0d\u8fc7\u4e5f\u6709\u5de5\u5177\u53ef\u4ee5\u4f7f\u7528\uff0c\u6bd4\u5982 valgrind\uff0c\u53ef\u4ee5\u81ea\u5df1\u5b89\u88c5\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install valgrind<\/pre>\n\n\n\n<p>\u901a\u8fc7valgrind\u8fd0\u884c\u53ef\u4ee5\u770b\u5230\uff08\u4e0a\u56fe\uff09\uff0c\u4e24\u4e2a\u7ea2\u6846\u5206\u522b\u6807\u51fa\u7684\u65e0\u6548\u5199\u5165\u548c\u65e0\u6548\u8bfb\u53d6\u7684\u5927\u5c0f\uff0c\u9ec4\u6846\u662f\u65e0\u6548\u64cd\u4f5c\u7684\u5730\u5740\uff0c\u6211\u7533\u8bf7\u7684\u662f2\u4e2a\u5927\u5c0f\uff08\u9ec4\u6846\u4e2d\u53ef\u4ee5\u770b\u5230\u7533\u8bf7\u7684\u662f8\u5b57\u8282\uff09\uff08\u5408\u6cd5\u53ef\u64cd\u4f5c\u7684\u662f p[0] \u548c p[1])\uff0c\u90a3\u4e48p[2]\u4f4d\u7f6e\u4e3a\u7b2c\u4e00\u4e2a\u8d8a\u754c\uff0c\u5b83\u7684\u5730\u5740\u662fp[1]\u7684\u7ed3\u5c3e\uff0c\u4e3a 0 bytes, \u73b0\u5728\u6211\u64cd\u4f5c\u7684\u662f p[3] \uff0c\u6211\u768464\u4f4d\u673a\u5668\u4e0aint\u662f4\u5b57\u8282\uff0c\u6240\u4ee5\u518d\u8d85\u51fa\u4e00\u4f4d\uff0c\u9519\u8bef\u64cd\u4f5c\u5730\u5740\u662f 4 bytes\u3002<\/p>\n\n\n\n<p>_________________________________________________________________________<\/p>\n\n\n\n<p>\u901a\u8fc7\u547d\u4ee4\u67e5\u770b\u7a0b\u5e8f\u8fd0\u884c\u65f6\u7684\u7a7a\u95f4\u5206\u914d\u60c5\u51b5<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/proc\/self\/maps<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"777\" height=\"734\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-011604.png\" alt=\"\" class=\"wp-image-476 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-011604.png 777w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-011604-300x283.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-011604-768x725.png 768w\" data-sizes=\"(max-width: 777px) 100vw, 777px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 777px; --smush-placeholder-aspect-ratio: 777\/734;\" \/><\/figure>\n\n\n\n<p>\u6bcf\u4e2a\u533a\u95f4\u90fd\u67094\u4e2a\u5c5e\u6027\uff1a<\/p>\n\n\n\n<p>r \u53ef\u4ee5\u8bfb\u53d6<\/p>\n\n\n\n<p>w \u53ef\u4ee5\u4fee\u6539<\/p>\n\n\n\n<p>x \u53ef\u4ee5\u6267\u884c<\/p>\n\n\n\n<p>p\/s \u662f\u5426\u4e3a\u5171\u4eab\u5185\u5b58<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u6709\u6587\u4ef6\u540d\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5c5e\u6027\u4e3a r-p \u6807\u8bc6\u5b58\u653e\u7684\u662f rodata\uff0c\u5c5e\u6027\u4e3arw-p \u6807\u8bc6\u5b58\u653e\u7684\u662fbss \u548c data\uff0c\u5c5e\u6027\u4e3a r-xp \u6807\u8bc6\u5b58\u653e\u7684\u662f text \u6570\u636e\uff1b\u5bf9\u4e8e\u6ca1\u6709\u6587\u4ef6\u540d\u7684\u5185\u5b58\u533a\u95f4\uff0c\u6807\u8bc6\u7528mmap\u6620\u5c04\u7684\u533f\u540d\u7a7a\u95f4\uff1b\u6587\u4ef6\u540d\u4e3a [stack] \u7684\u5185\u5b58\u533a\u95f4\u6807\u8bc6\u7684\u662f \u6808 \uff1b\u6587\u4ef6\u540d\u4e3a [heap] \u7684\u5185\u5b58\u533a\u95f4\u8868\u793a\u7684\u662f\u5806\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%86%85%E5%AD%98%E5%88%86%E9%85%8D\"><\/span>\u5185\u5b58\u5206\u914d<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5185\u5b58\u5206\u914d\u65b9\u5f0f\u67093\u79cd\uff1a<\/p>\n\n\n\n<p>\uff081\uff09\u4ece\u9759\u6001\u50a8\u5b58\u533a\u57df\u5206\u914d\u3002\u5185\u5b58\u5728\u7a0b\u5e8f\u7f16\u8bd1\u65f6\u5c31\u5df2\u7ecf\u5206\u914d\u597d\uff0c\u8fd9\u5757\u5185\u5b58\u5728\u7a0b\u5e8f\u7684\u6574\u4e2a\u8fd0\u884c\u671f\u95f4\u90fd\u5b58\u5728\uff0c\u5982\u5168\u5c40\u53d8\u91cf\uff0c\u9759\u6001\u53d8\u91cf\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u5728\u6808\u4e0a\u521b\u5efa\u3002\u5728\u6267\u884c\u51fd\u6570\u65f6\uff0c\u51fd\u6570\u5185\u5c40\u90e8\u53d8\u91cf\u7684\u50a8\u5b58\u5355\u5143\u90fd\u53ef\u4ee5\u5728\u6808\u4e0a\u521b\u5efa\uff0c\u51fd\u6570\u6267\u884c\u7ed3\u675f\u65f6\u8fd9\u4e9b\u50a8\u5b58\u5355\u5143\u81ea\u52a8\u88ab\u91ca\u653e\u3002\u6808\u5185\u5b58\u5206\u914d\u8fd0\u7b97\u4f7f\u7528\u5185\u7f6e\u4e8e\u5904\u7406\u5668\u7684\u6307\u4ee4\u96c6\uff0c\u6548\u7387\u5f88\u9ad8\uff0c\u4f46\u5206\u914d\u7684\u5185\u5b58\u5bb9\u91cf\u6709\u9650\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u5728\u5806\u4e0a\u5206\u914d\uff0c\u4e5f\u79f0\u52a8\u6001\u5185\u5b58\u5206\u914d\u3002\u7a0b\u5e8f\u5728\u8fd0\u884c\u65f6\u7533\u8bf7\u6240\u9700\u8981\u7684\u5185\u5b58\uff0c\u7a0b\u5e8f\u5458\u53ef\u4ee5\u81ea\u5df1\u51b3\u5b9a\u5728\u4ec0\u4e48\u65f6\u5019\u91ca\u653e\u5185\u5b58\u3002\u52a8\u6001\u5185\u5b58\u7684\u751f\u5b58\u671f\u7531\u7a0b\u5e8f\u5458\u51b3\u5b9a\uff0c\u4f7f\u7528\u975e\u5e38\u7075\u6d3b\uff0c\u4f46\u95ee\u9898\u4e5f\u6700\u591a\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%87%8E%E6%8C%87%E9%92%88\"><\/span>\u91ce\u6307\u9488<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u91ce\u6307\u9488\u4e0d\u662f NULL \u6307\u9488\uff0c\u662f\u6307\u5411\u201c\u5783\u573e\u5185\u5b58\u201d\u7684\u6307\u9488\uff0c\u91ce\u6307\u9488\u662f\u5f88\u5371\u9669\u7684\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u7a0b\u5e8f\u6bd4\u8f83\u957f\uff0c\u6211\u4eec\u6709\u65f6\u5019\u8bb0\u4e0d\u4f4f\u6709\u6ca1\u6709\u91ca\u653e\u5185\u5b58\uff0c\u901a\u5e38\u4f7f\u7528 \u201dif (ptr != NULL)\u201c \u8fdb\u884c\u9632\u9519\u5904\u7406\uff0c\u4f46\u662f\u9057\u61be\u7684\u662f\uff0c\u6b64\u65f6if\u8bed\u53e5\u4e0d\u8d77\u4f5c\u7528\uff0c\u56e0\u4e3a\u5373\u4fbf ptr \u4e0d\u662f NULL\u6307\u9488\uff0c\u5b83\u4e5f\u4e0d\u6307\u5411\u5408\u6cd5\u7684\u5185\u5b58\u5757\u3002\u4e0b\u9762\u4ee3\u7801\u79cd\u5c31\u6d89\u53ca\u5230\u64cd\u4f5c\u91ca\u653e\u4e86\u7684\u5185\u5b58\uff0c\u5c3d\u7ba1\u7f16\u8bd1\u548c\u8fd0\u884c\u90fd\u6ca1\u6709\u51fa\u9519\uff0c\u4f46\u662f\u5374\u53c8\u662f\u4e00\u4e2a\u6f5c\u5728\u7684bug\uff0c\u4e0d\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u7206\u53d1\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"559\" height=\"803\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-015304.png\" alt=\"\" class=\"wp-image-483 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-015304.png 559w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-015304-209x300.png 209w\" data-sizes=\"(max-width: 559px) 100vw, 559px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 559px; --smush-placeholder-aspect-ratio: 559\/803;\" \/><\/figure>\n\n\n\n<p>\u91ce\u6307\u9488\u7684\u6210\u56e0\u4e3b\u8981\u6709\u4e24\u79cd\uff1a<\/p>\n\n\n\n<p>\uff081\uff09\u6307\u9488\u53d8\u91cf\u6ca1\u6709\u88ab\u521d\u59cb\u5316\u3002\u4efb\u4f55\u6307\u9488\u53d8\u91cf\u5728\u521a\u521b\u5efa\u7684\u65f6\u5019\u90fd\u4e0d\u4f1a\u81ea\u52a8\u88ab\u521d\u59cb\u5316\u4e3a NULL\u6307\u9488\uff0c\u5b83\u7684\u9ed8\u8ba4\u503c\u662f\u968f\u673a\u7684\u3002\u6240\u4ee5\uff0c\u6307\u9488\u53d8\u91cf\u5728\u521b\u5efa\u7684\u540c\u65f6\u5e94\u8be5\u88ab\u521d\u59cb\u5316\uff0c\u8981\u4e48\u5c06\u6307\u9488\u521d\u59cb\u5316\u4e3a NULL\uff0c\u8981\u4e48\u5206\u914d\u5185\u5b58\u5e76\u521d\u59cb\u5316\u7ed9\u5b83\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u6307\u9488\u88ab\u91ca\u653e\u540e\uff0c\u6ca1\u6709\u8bbe\u7f6e\u4e3a NULL\uff0c\u8ba9\u4eba\u8bef\u8ba4\u4e3a\u5b83\u8fd8\u662f\u4e2a\u5408\u6cd5\u7684\u989d\u6307\u9488\u3002free \uff08\u4ee5\u53caC++\u79cd\u7684 delete\uff09\u53ea\u662f\u628a\u6307\u9488\u6307\u5411\u7684\u5185\u5b58\u7ed9\u91ca\u653e\u6389\uff0c\u4f46\u5e76\u6ca1\u6709\u628a\u6307\u9488\u672c\u8eab\u5220\u9664\u6389\u3002\u5373\u8be5\u5730\u5740\u5bf9\u5e94\u7684\u5185\u5b58\u53d8\u6210\u4e86\u201c\u5783\u573e\u201d\uff0c\u8fd9\u4e2a\u6307\u9488\u6210\u4e86\u201c\u91ce\u6307\u9488\u201d\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%B8%B8%E8%A7%81%E5%86%85%E5%AD%98%E9%94%99%E8%AF%AF\"><\/span>\u5e38\u89c1\u5185\u5b58\u9519\u8bef<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u53d1\u751f\u5185\u5b58\u9519\u8bef\u662f\u975e\u5e38\u9ebb\u70e6\u7684\u4e8b\u3002\u7f16\u8bd1\u5668\u4e0d\u80fd\u81ea\u52a8\u53d1\u73b0\u8fd9\u4e9b\u9519\u8bef\uff0c\u901a\u5e38\u662f\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u624d\u80fd\u6355\u6349\u5230\uff0c\u800c\u8fd9\u4e9b\u9519\u8bef\u5927\u90fd\u6ca1\u6709\u660e\u663e\u7684\u75c7\u72b6\uff0c\u65f6\u9690\u65f6\u73b0\uff0c\u589e\u52a0\u4e86\u6539\u9519\u7684\u96be\u5ea6\u3002<\/p>\n\n\n\n<p>\uff081\uff09\u5185\u5b58\u5206\u914d\u672a\u6210\u529f\uff0c\u5374\u4f7f\u7528\u4e86\u5b83\u3002\u5728\u4f7f\u7528\u5185\u5b58\u524d\u5148\u68c0\u67e5\u6307\u9488\u662f\u5426\u4e3a NULL\u3002\u5982\u679c\u6307\u9488\u662f\u51fd\u6570\u7684\u53c2\u6570\uff0c\u90a3\u4e48\u5728\u51fd\u6570\u7684\u5165\u53e3\u5904\u7528 \u201cassert(ptr != NULL)\u201d\u8fdb\u884c\u68c0\u67e5\uff1b\u5982\u679c\u662f\u81ea\u5df1\u7533\u8bf7\u7684\u5185\u5b58\uff0c\u5e94\u8be5\u7528\u201cif (ptr != NULL)\u201d \u6216 \u201cif (ptr == NULL)\u201d \u8fdb\u884c\u9632\u9519\u5904\u7406\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u5185\u5b58\u5206\u914d\u6210\u529f\uff0c\u4f46\u662f\u5c1a\u672a\u521d\u59cb\u5316\u5c31\u5f15\u7528\u5b83\u3002\u5185\u5b58\u7684\u9ed8\u8ba4\u521d\u59cb\u503c\u7a76\u7adf\u662f\u4ec0\u4e48\u5e76\u6ca1\u6709\u7edf\u4e00\u7684\u6807\u51c6\uff0c\u6240\u4ee5\u65e0\u8bba\u7528\u4f55\u79cd\u65b9\u5f0f\u521b\u5efa\u6570\u7ec4\uff0c\u522b\u5fd8\u4e86\u8d4b\u521d\u503c\uff0c\u5373\u4fbf\u662f\u8d4b0\u503c\u4e5f\u4e0d\u8981\u7701\u7565\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u5185\u5b58\u5206\u914d\u6210\u529f\u4e14\u5df2\u7ecf\u521d\u59cb\u5316\uff0c\u4f46\u64cd\u4f5c\u8d8a\u754c\u3002\u4e0a\u9762\u4ecb\u7ecd\u5806\u533a\uff0c\u4e3e\u4f8b\u7684\u4ee3\u7801\u5c31\u662f\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n\n\n\n<p>\uff084\uff09\u5fd8\u8bb0\u4e86\u91ca\u653e\u5185\u5b58\uff0c\u9020\u6210\u5185\u5b58\u6cc4\u6f0f\u3002\u542b\u6709\u8fd9\u79cd\u9519\u8bef\u7684\u51fd\u6570\u6bcf\u88ab\u8c03\u7528\u4e00\u6b21\u5c31\u4e22\u5931\u4e00\u5757\u5185\u5b58\u3002\u521a\u5f00\u59cb\u7cfb\u7edf\u7684\u5185\u5b58\u5145\u8db3\uff0c\u4e0d\u5bb9\u6613\u770b\u5230\u9519\u8bef\uff0c\u603b\u6709\u4e00\u6b21\u7a0b\u5e8f\u4f1a\u7a81\u7136\u6b7b\u6389\uff0c\u7cfb\u7edf\u51fa\u73b0\u5185\u5b58\u8017\u5c3d\u7684\u63d0\u793a\u3002\u52a8\u6001\u5185\u5b58\u7684\u7533\u8bf7\u4e0e\u91ca\u653e\u5fc5\u987b\u914d\u5bf9\uff0c\u7533\u8bf7\u591a\u5c11\u6b21\u5c31\u5e94\u8be5\u91ca\u653e\u591a\u5c11\u6b21\uff0c\u5426\u5219\u6307\u4e0d\u5b9a\u4ec0\u4e48\u65f6\u5019\u5c31\u51fa\u9519\u4e86\u3002<\/p>\n\n\n\n<p>\uff085\uff09\u91ca\u653e\u4e86\u5185\u5b58\u5374\u7ee7\u7eed\u4f7f\u7528\u5b83\uff1a<\/p>\n\n\n\n<p>\u2460 \u7a0b\u5e8f\u4e2d\u5bf9\u8c61\u8c03\u7528\u5173\u7cfb\u8fc7\u4e8e\u590d\u6742\uff0c\u5b9e\u5728\u96be\u4ee5\u641e\u6e05\u695a\u67d0\u4e2a\u5bf9\u8c61\u7a76\u7adf\u662f\u5426\u5df2\u7ecf\u91ca\u653e\u4e86\u5185\u5b58\uff0c\u6b64\u65f6\u5e94\u8be5\u91cd\u65b0\u8bbe\u8ba1\u6570\u636e\u7ed3\u6784\uff0c\u4ece\u6839\u672c\u4e0a\u89e3\u51b3\u5bf9\u8c61\u7ba1\u7406\u7684\u6df7\u4e71\u5c40\u9762\u3002<\/p>\n\n\n\n<p>\u2461 \u51fd\u6570\u7684 return \u8bed\u53e5\u5199\u9519\u4e86\uff0c\u6ce8\u610f\u4e0d\u8981\u8fd4\u56de\u6307\u5411 \u201c\u6808\u5185\u5b58\u201d \u7684\u6307\u9488\uff0c\u56e0\u4e3a\u8be5\u5185\u5b58\u5728\u51fd\u6570\u4f53\u7ed3\u675f\u65f6\u88ab\u81ea\u52a8\u9500\u6bc1\u4e86\u3002<\/p>\n\n\n\n<p>\u2462 \u91ca\u653e\u5185\u5b58\u540e\uff0c\u6ca1\u6709\u5c06\u6307\u9488\u8bbe\u7f6e\u4e3a NULL\uff0c\u5bfc\u81f4\u4ea7\u751f\u91ce\u6307\u9488\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%AE%B5%E9%94%99%E8%AF%AF%E5%8F%8A%E8%B0%83%E8%AF%95%E6%96%B9%E6%B3%95\"><\/span>\u6bb5\u9519\u8bef\u53ca\u8c03\u8bd5\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u6bb5\u9519\u8bef\u5c31\u662f\u8bbf\u95ee\u4e86\u9519\u8bef\u7684\u5185\u5b58\u6bb5\uff0c\u4e00\u822c\u662f\u6ca1\u6709\u6743\u9650\uff0c\u6216\u8005\u6839\u672c\u5c31\u4e0d\u5b58\u5728\u5bf9\u5e94\u7684\u7269\u7406\u5730\u5740\uff0c\u5c24\u5176\u662f\u5e38\u89c1\u7684\u8bbf\u95ee 0 \u5730\u5740\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u6765\u8bf4\uff0c\u6bb5\u9519\u8bef\u5c31\u662f\u6307\u8bbf\u95ee\u8d85\u51fa\u4e86\u7cfb\u7edf\u6240\u7ed9\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u901a\u5e38\u8fd9\u4e2a\u503c\u662f\u7531 gdtr \u6765\u4fdd\u5b58\u7684\uff0c\u5b83\u662f\u4e00\u4e2a48\u4f4d\u7684\u5bc4\u5b58\u5668\uff0c\u5176\u4e2d32\u4f4d\u7528\u4e8e\u4fdd\u5b58\u7531\u5b83\u6307\u5411\u7684 gdt \u8868\uff1b\u540e13\u4f4d\u7528\u4e8e\u4fdd\u5b58\u76f8\u5e94\u7684 gdt \u4e0b\u6807\uff1b\u6700\u540e3\u4f4d\u5305\u62ec\u4e86\u7a0b\u5e8f\u662f\u5426\u5728\u5185\u5b58\u4e2d\uff0c\u4ee5\u53ca\u7a0b\u5e8f\u5728CPU\u79cd\u7684\u8fd0\u884c\u7ea7\u522b\u3002\u6307\u5411 gdt \u662f\u4e00\u4e2a\u4ee5 64 \u4f4d\u4e3a\u5355\u4f4d\u7684\u8868\uff0c\u5728\u8fd9\u5f20\u8868\u4e2d\u4fdd\u5b58\u7740\u7a0b\u5e8f\u8fd0\u884c\u7684\u4ee3\u7801\u6bb5\u3001\u6570\u636e\u6bb5\u7684\u8d77\u59cb\u5730\u5740\uff0c\u4ee5\u53ca\u4e0e\u6b64\u76f8\u5bf9\u5e94\u7684\u6bb5\u9650\u548c\u9875\u9762\u4ea4\u6362\u8fd8\u6709\u7a0b\u5e8f\u7684\u8fd0\u884c\u7ea7\u522b\uff0c\u4ee5\u53ca\u5185\u5b58\u7c92\u5ea6\u7b49\u4fe1\u606f\u3002\u4e00\u65e6\u4e00\u4e2a\u7a0b\u5e8f\u53d1\u751f\u4e86\u8d8a\u754c\u8bbf\u95ee\uff0cCPU\u5c31\u4f1a\u4ea7\u751f\u76f8\u5e94\u7684\u5f02\u5e38\u4fdd\u62a4\uff0c\u4e8e\u662f <span style=\"color:#a30023\" class=\"has-inline-color\">segmentation fault<\/span> \u5c31\u51fa\u73b0\u4e86\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5728\u7528 C\/C++ \u7f16\u5199\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u5185\u5b58\u7ba1\u7406\u7684\u7edd\u5927\u90e8\u5206\u5de5\u4f5c\u90fd\u5c5e\u9700\u8981\u6211\u4eec\u6765\u505a\u7684\u3002\u5b9e\u9645\u4e0a\u5185\u5b58\u7ba1\u7406\u662f\u4e00\u4e2a\u6807\u80f6\u7e41\u7410\u7684\u5de5\u4f5c\uff0c\u65e0\u8bba\u4f60\u591a\u9ad8\u660e\uff0c\u7ecf\u9a8c\u591a\u4e30\u5bcc\uff0c\u96be\u514d\u4f1a\u5728\u6b64\u5904\u72af\u4e9b\u5c0f\u9519\u8bef\uff0c\u800c\u901a\u5e38\u8fd9\u4e9b\u9519\u8bef\u53c8\u90a3\u4e48\u6d45\u663e\u800c\u6613\u4e8e\u6d88\u9664\u3002\u4f46\u662f\u624b\u52a8\u5bfb\u627ebug\u5f80\u5f80\u662f\u4f4e\u6548\u4e14\u8ba9\u4eba\u538c\u6076\u7684\uff0c\u4e0b\u9762\u5c31\u8c08\u8c08\u5982\u4f55\u5feb\u901f\u5b9a\u4f4d&#8221;\u6bb5\u9519\u8bef\u201c\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u5c31\u7528\u8fd9\u6bb5\u5b58\u5728\u6bb5\u9519\u8bef\u7684\u4ee3\u7801\u6765\u793a\u8303\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">void segmentation(void)\n{\n    unsigned char *ptr = 0x00;\n    *ptr = 0x00;\n}\n\nint main(void)\n{\n    segmentation();\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"839\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104320-1024x839.png\" alt=\"\" class=\"wp-image-488 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104320-1024x839.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104320-300x246.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104320-768x629.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104320.png 1052w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/839;\" \/><\/figure>\n\n\n\n<p><strong>gdb\u8c03\u8bd5<\/strong><\/p>\n\n\n\n<p>\u7f16\u8bd1\u7684\u65f6\u5019\u52a0\u4e0a <span style=\"color:#3d00a3\" class=\"has-inline-color\">-g -rdynamic<\/span> \u53c2\u6570\uff0c\u7136\u540e\u7528 <span style=\"color:#26a300\" class=\"has-inline-color\">gdb .\/[\u7a0b\u5e8f\u6587\u4ef6\u540d] <\/span>\u8fd0\u884c<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"532\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104839-1024x532.png\" alt=\"\" class=\"wp-image-489 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104839-1024x532.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104839-300x156.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104839-768x399.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-104839.png 1067w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/532;\" \/><\/figure>\n\n\n\n<p>\u6211\u4e00\u822c\u90fd\u4e0d\u7528\u547d\u4ee4\u6572 gdb \u8c03\u8bd5\uff0c\u5728 vscode \u91cc\u6dfb\u52a0 C\/C++ \u63d2\u4ef6\uff0c\u7f16\u8bd1\u597d\u540e,<\/p>\n\n\n\n<p>\u6309 F5 \uff0c\u9ed8\u8ba4\u9009\u9879\u5728\u7b2c\u4e00\u4e2a gdb \u4e0a\uff0c\u56de\u8f66<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1021\" height=\"815\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105250.png\" alt=\"\" class=\"wp-image-490 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105250.png 1021w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105250-300x239.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105250-768x613.png 768w\" data-sizes=\"(max-width: 1021px) 100vw, 1021px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1021px; --smush-placeholder-aspect-ratio: 1021\/815;\" \/><\/figure>\n\n\n\n<p>\u9009\u62e9\u9ed8\u8ba4\u914d\u7f6e\uff0c\u56de\u8f66<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"836\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105400-1024x836.png\" alt=\"\" class=\"wp-image-491 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105400-1024x836.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105400-300x245.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105400-768x627.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105400.png 1037w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/836;\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e0b\u751f\u6210\u4e86\u914d\u7f6e\u6587\u4ef6\uff08\u7ea2\u6846\uff09\uff0c\u7136\u540e\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff0c\u9ec4\u6846\u90e8\u5206\u7528\u4e8e\u6307\u5b9a\u53ef\u6267\u884c\u7a0b\u5e8f\u6587\u4ef6\u8def\u5f84\uff0c\u5c06\u84dd\u8272\u6846\u7684\u4e2d\u6587\u6587\u5b57\u548c\u7a7a\u683c\u5220\u6389\uff0c$\u7b26\u53f7\u8ddf\u7740\u82b1\u62ec\u53f7\u90a3\u6bb5\u8868\u793a\u8def\u5f84\u4e3a\u5f53\u524d\u9879\u76ee\u6587\u4ef6\u5939\u6839\uff0c\u7136\u540e\u7d2b\u8272\u6846\u90e8\u5206\u6539\u4e3a\u751f\u6210\u7684\u53ef\u6267\u884c\u6587\u4ef6\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e0b\u7684\u76f8\u5bf9\u8def\u5f84\uff0c\u7136\u540e\u6309 Ctrl + S\u4fdd\u5b58\uff0cCtrl + W\u5173\u95ed\u5f53\u524d\u7684\u7f16\u8f91\u6846\uff0c\u4e4b\u540e\u6309 F5 \u5c31\u53ef\u4ee5\u8c03\u8bd5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"834\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105456-1024x834.png\" alt=\"\" class=\"wp-image-492 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105456-1024x834.png 1024w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105456-300x244.png 300w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105456-768x626.png 768w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-105456.png 1036w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/834;\" \/><\/figure>\n\n\n\n<p>\u6211\u8fd9\u91cc\u662f\u901a\u8fc7\u914d\u7f6e\u7684 cmake \u8fdb\u884c\u7f16\u8bd1\uff0c\u4f7f\u7528\u7684\u6a21\u677f\u5df2\u7ecf\u5728\u524d\u9762<a target=\"_blank\" href=\"https:\/\/blog.iyatt.com\/linux%e5%bc%80%e5%8f%91\/2021\/04\/22\/%e5%b7%a5%e7%a8%8b%e7%ae%a1%e7%90%86%ef%bc%88cmake%ef%bc%89\/\" rel=\"noopener\">\u5de5\u7a0b\u7ba1\u7406<\/a>\u5217\u51fa\u6765\u4e86\uff0c\u8fd9\u4e2a\u6a21\u677f\u4e2d\u6211\u8bbe\u5b9a\u7684\u662f\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff08\u6587\u4ef6\u540d\u4e3a demo\uff09\u653e\u5165\u5230\u9879\u76ee\u6587\u4ef6\u5939\u4e0b\u7684 bin \u76ee\u5f55\u4e2d \uff08cmake\u7684\u65f6\u5019\u4f1a\u521b\u5efa\u8fd9\u4e2a\u76ee\u5f55\uff09\u3002\u6240\u4ee5\u6211\u8fd9\u91cc\u6539\u4e3a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"664\" height=\"532\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110231.png\" alt=\"\" class=\"wp-image-493 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110231.png 664w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110231-300x240.png 300w\" data-sizes=\"(max-width: 664px) 100vw, 664px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 664px; --smush-placeholder-aspect-ratio: 664\/532;\" \/><\/figure>\n\n\n\n<p>\u7136\u540e\u76f4\u63a5\u6309 F5 \u8c03\u8bd5\u8fd0\u884c\uff08\u6ce8\u610f\u5148\u7f16\u8bd1\uff0c\u624d\u80fd\u8c03\u8bd5\uff0c\u4e0d\u7136\u7a0b\u5e8f\u6587\u4ef6\u90fd\u4e0d\u5b58\u5728\uff0c\u4f60\u8fd0\u884c\u8c03\u8bd5\u5565\uff09\uff0c\u76f4\u63a5\u6307\u51fa\u9519\u8bef\u4f4d\u7f6e\uff0c\u66f4\u4e3a\u6613\u7528\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"729\" height=\"837\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110811.png\" alt=\"\" class=\"wp-image-494 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110811.png 729w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-110811-261x300.png 261w\" data-sizes=\"(max-width: 729px) 100vw, 729px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 729px; --smush-placeholder-aspect-ratio: 729\/837;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%88%86%E6%9E%90_core_%E6%96%87%E4%BB%B6\"><\/span>\u5206\u6790 core \u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u8be6\u60c5\u53ef\u4ee5\u4f7f\u7528 <span style=\"color:#a3003e\" class=\"has-inline-color\">man 5 core<\/span> \u67e5\u9605<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"785\" height=\"899\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-120418.png\" alt=\"\" class=\"wp-image-497 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-120418.png 785w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-120418-262x300.png 262w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-120418-768x880.png 768w\" data-sizes=\"(max-width: 785px) 100vw, 785px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 785px; --smush-placeholder-aspect-ratio: 785\/899;\" \/><\/figure>\n\n\n\n<p>\u6211\u4f7f\u7528\u7684 Kali Linux \u9ed8\u8ba4\u7981\u6b62\u4e86 core \u6587\u4ef6\u7684\u4ea7\u751f\uff0c\u4f7f\u7528 <span style=\"color:#00a30a\" class=\"has-inline-color\">ulimit -c<\/span> \u67e5\u770b\uff0c\u53d1\u73b0\u4e3a 0\uff0c\u5373\u6ca1\u6709\u4e3a core \u8bbe\u7f6e\u50a8\u5b58\u7a7a\u95f4\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"291\" height=\"198\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-120633.png\" alt=\"\" class=\"wp-image-498 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 291px; --smush-placeholder-aspect-ratio: 291\/198;\" \/><\/figure>\n\n\n\n<p>\u90a3\u4e48\u6211\u7528\u547d\u4ee4\u4e34\u65f6\u8bbe\u7f6e core \uff08\u53ea\u5728\u5f53\u524d\u6267\u884c\u4fee\u6539\u547d\u4ee4\u7684\u7ec8\u7aef\u7a97\u53e3\u6709\u6548\uff09\uff0c\u8bbe\u7f6e core \u5927\u5c0f\u9650\u5236\u4e3a 512KB<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ulimit-c 1000<\/pre>\n\n\n\n<p>\u7136\u540e\u7f16\u8bd1\u7a0b\u5e8f\u548c\u6267\u884c\uff08\u7f16\u8bd1\u7684\u65f6\u5019\u81f3\u5c11\u8981\u52a0\u4e0a -g \u53c2\u6570\uff0c\u4f1a\u5c06\u6e90\u7801\u6587\u672c\u653e\u5165\u7a0b\u5e8f\u6587\u4ef6\u4e2d\uff0c\u65b9\u4fbf\u8c03\u8bd5\u7684\u65f6\u5019\u80fd\u591f\u76f4\u63a5\u7ed9\u4f60\u5b9a\u4f4d\u6307\u51fa\u4ee3\u7801\u9519\u8bef\u4f4d\u7f6e\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"511\" height=\"273\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121312.png\" alt=\"\" class=\"wp-image-501 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121312.png 511w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121312-300x160.png 300w\" data-sizes=\"(max-width: 511px) 100vw, 511px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 511px; --smush-placeholder-aspect-ratio: 511\/273;\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u770b\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u4ea7\u751f\u4e86 core \u6587\u4ef6<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"429\" height=\"166\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121011.png\" alt=\"\" class=\"wp-image-500 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121011.png 429w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121011-300x116.png 300w\" data-sizes=\"(max-width: 429px) 100vw, 429px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 429px; --smush-placeholder-aspect-ratio: 429\/166;\" \/><\/figure>\n\n\n\n<p>\u7136\u540e\u5206\u6790 core \u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4e5f\u662f\u6307\u51fa\u4e86\u7b2c\u56db\u884c\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">gdb [\u7a0b\u5e8f\u6587\u4ef6\u8def\u5f84(\u6587\u4ef6\u540d)] core<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"631\" height=\"494\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121540.png\" alt=\"\" class=\"wp-image-502 lazyload\" data-srcset=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121540.png 631w, https:\/\/blog.iyatt.com\/wp-content\/uploads\/2021\/04\/\u5c4f\u5e55\u622a\u56fe-2021-04-24-121540-300x235.png 300w\" data-sizes=\"(max-width: 631px) 100vw, 631px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 631px; --smush-placeholder-aspect-ratio: 631\/494;\" \/><\/figure>\n\n\n\n<p>\u6b64\u6cd5\u9002\u5408\u5728\u8fd0\u884c\u7a0b\u5e8f\u65f6\uff0c\u6ca1\u6709\u51c6\u5907gdb\u8c03\u8bd5\uff0c\u4f46\u662f\u610f\u5916\u9047\u5230\u4e86\u9519\u8bef\uff0c\u53ef\u4ee5\u901a\u8fc7\u9519\u8bef\u65f6\u4ea7\u751f\u7684 core \u6587\u4ef6\u8fdb\u884c\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u5b58\u653e 64\u4f4d\u5206\u5e03\u8981\u590d\u6742\u4e9b\uff0c\u5bfb\u5740\u7a7a\u95f4\u5e76\u4e0d\u662f64\u4f4d\uff0c\u4f7f\u7528\u5176\u4e2d\u4e00\u90e8\u5206\uff0c\u5176\u5b83\u4f5c\u4e3a\u6269\u5c55\uff0c\u5206\u5e03\u770b\u60c5\u51b5\u800c\u5b9a\u3002\u7406\u89e3\u5927\u4f53\u5206\u5e03 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1,607],"tags":[],"class_list":["post-468","post","type-post","status-publish","format-standard","hentry","category-all","category-linux-"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=468"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/468\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}