{"id":119560,"date":"2026-10-29T23:24:52","date_gmt":"2026-10-29T15:24:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119560.html"},"modified":"2026-10-29T23:24:52","modified_gmt":"2026-10-29T15:24:52","slug":"%e4%bd%a0%e7%9a%84%e6%a0%88%e5%88%b0%e5%ba%95%e6%9c%89%e5%a4%9a%e5%a4%a7%ef%bc%9a%e7%88%86%e6%a0%88%e4%b8%8e%e4%bb%bb%e5%8a%a1%e6%a0%88%e8%ae%a1%e7%ae%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119560.html","title":{"rendered":"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97"},"content":{"rendered":"<p>\u5148\u731c\u7ed3\u679c\u3002\u8fd9\u6bb5\u5931\u63a7\u9012\u5f52&#xff0c;\u5206\u522b\u5728\u4e24\u4e2a\u5e73\u53f0\u4e0a\u8dd1\u4f1a\u600e\u6837&#xff1f;<\/p>\n<p><span class=\"token keyword\">void<\/span> <span class=\"token function\">recurse<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> n<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">char<\/span> pad<span class=\"token punctuation\">[<\/span><span class=\"token number\">4096<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>       <span class=\"token comment\">\/* \u6bcf\u5c42\u591a\u5360 4KB *\/<\/span><br \/>\n    <span class=\"token function\">recurse<\/span><span class=\"token punctuation\">(<\/span>n <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>       <span class=\"token comment\">\/* \u6ca1\u6709\u51fa\u53e3 *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5728 Linux \u4e0a&#xff08;\u4ee5\u9ed8\u8ba4 -O0 \u7f16\u8bd1&#xff1b;\u82e5\u5f00 -O2 \u4ee5\u4e0a\u4f18\u5316&#xff0c;\u8fd9\u4e2a\u5c3e\u9012\u5f52\u4f1a\u88ab\u6539\u5199\u6210\u5faa\u73af&#xff0c;\u6c38\u8fdc\u8dd1\u4e0d\u7206&#xff09;&#xff0c;\u5b83\u8f70\u8f70\u70c8\u70c8\u5730\u6b7b&#xff1a;\u6808\u4e00\u8def\u751f\u957f\u89e6\u5230\u4e0a\u9650&#xff0c;\u89e6\u53d1\u6bb5\u9519\u8bef&#xff0c;Segmentation fault \u660e\u660e\u767d\u767d\u3002\u5728\u4e00\u5757 Cortex-M \u5355\u7247\u673a\u4e0a&#xff0c;\u5b83\u53ef\u80fd\u4ec0\u4e48\u63d0\u793a\u90fd\u6ca1\u6709&#xff1a;\u6808\u6307\u9488\u6084\u6084\u8d8a\u8fc7\u8fb9\u754c&#xff0c;\u628a\u76f8\u90bb\u5185\u5b58\u91cc\u7684\u6570\u636e\u4e00\u4e2a\u4e00\u4e2a\u8986\u76d6\u6389&#xff0c;\u522b\u7684\u4efb\u52a1\u7684\u4e0a\u4e0b\u6587\u3001\u961f\u5217\u53e5\u67c4\u3001\u914d\u7f6e\u53d8\u91cf&#xff0c;\u8c01\u4f4f\u5f97\u8fd1\u8c01\u906d\u6b83\u3002\u7a0b\u5e8f\u7ee7\u7eed\u8dd1&#xff0c;\u53ea\u662f\u5f00\u59cb&#034;\u5076\u5c14\u62bd\u98ce&#034;&#xff0c;\u800c\u4e14\u6bcf\u6b21\u62bd\u98ce\u7684\u4f4d\u7f6e\u90fd\u4e0d\u4e00\u6837\u3002\u540c\u4e00\u4e2a bug&#xff0c;\u4e24\u79cd\u6b7b\u76f8&#xff0c;\u5dee\u8ddd\u5168\u5728&#034;\u6709\u6ca1\u6709\u4eba\u5bf9\u6808\u8bbe\u9632&#034;\u3002\u8fd9\u4e00\u7bc7\u628a\u6808\u7684\u8d26\u672c\u91cf\u5230\u5e95&#xff1a;\u4e0a\u9650\u4ece\u54ea\u6765\u3001\u7206\u6808\u600e\u4e48\u4e2a\u6b7b\u6cd5\u3001\u9700\u6c42\u600e\u4e48\u7b97\u3001\u4e09\u9053\u95f8\u600e\u4e48\u8bbe\u3002<\/p>\n<h3>\u4e00\u3001\u4e09\u4e2a\u4e16\u754c&#xff0c;\u4e09\u79cd\u6808\u4e0a\u9650<\/h3>\n<p>\u6808\u4e0d\u662f\u65e0\u9650\u8d44\u6e90&#xff0c;\u4e0a\u9650\u7531\u6240\u5728\u5e73\u53f0\u89c4\u5b9a&#xff0c;\u800c\u4e14\u5dee\u8ddd\u60ac\u6b8a\u3002<\/p>\n<p>Linux \u4e3b\u7ebf\u7a0b\u7684\u6808\u4e0a\u9650\u9ed8\u8ba4 8MB&#xff08;ulimit -s \u53ef\u67e5\u53ef\u6539&#xff0c;\u5185\u6838\u4fa7\u5bf9\u5e94 RLIMIT_STACK&#xff09;\u3002\u6ce8\u610f\u7bc7 16 \u8bb2\u8fc7\u7684\u6309\u9700\u8c03\u9875\u5728\u8fd9\u91cc\u540c\u6837\u751f\u6548&#xff1a;8MB \u662f\u4e0a\u9650\u800c\u975e\u5b9e\u5360&#xff0c;\u6808\u9875\u6309\u9700\u9010\u9875\u6302\u8fdb\u9875\u8868&#xff0c;\u89e6\u78b0\u54ea\u9875\u5206\u914d\u54ea\u9875&#xff0c;\u6240\u4ee5&#034;\u7a0b\u5e8f\u6ca1\u5403\u6ee1 8MB&#034;\u4e0d\u4ee3\u8868\u5b83\u7533\u8bf7\u4e0d\u5230 8MB\u3002\u7ebf\u7a0b\u7684\u6808\u5728\u521b\u5efa\u65f6\u4e00\u6b21\u6027 mmap&#xff0c;glibc \u9ed8\u8ba4\u5927\u5c0f\u8ddf\u968f ulimit -s&#xff0c;\u9700\u8981\u66f4\u5c0f\/\u66f4\u5927\u65f6\u7528 pthread_attr_setstacksize \u663e\u5f0f\u6307\u5b9a\u3002<\/p>\n<p>\u5185\u6838\u6808\u7684\u6570\u5b57\u8981\u5c0f\u4e09\u4e2a\u6570\u91cf\u7ea7&#xff1a;x86-64 \u4e0a\u901a\u5e38\u53ea\u6709 16KB\u3002\u9a71\u52a8\u5f00\u53d1\u7531\u6b64\u6709\u4e00\u6761\u94c1\u5f8b\u2014\u2014\u5185\u6838\u6001\u7981\u5927\u5c40\u90e8\u6570\u7ec4\u3001\u7981\u6df1\u9012\u5f52\u2014\u2014\u4f60\u5199\u7684\u6bcf\u4e00\u5c42\u51fd\u6570\u8c03\u7528\u3001\u6bcf\u4e00\u4e2a char buf[4096]&#xff0c;\u90fd\u5728\u8ddf\u4e2d\u65ad\u5904\u7406\u5171\u4eab\u8fd9 16KB\u3002\u7528\u6237\u6001&#034;\u968f\u624b\u5f00\u4e2a\u5927\u6570\u7ec4&#034;\u7684\u4e60\u60ef&#xff0c;\u642c\u8fdb\u5185\u6838\u5c31\u662f\u7206\u6808\u4e8b\u6545\u3002<\/p>\n<p>RTOS \u4e16\u754c\u66f4\u7d27&#xff1a;\u6bcf\u4e2a\u4efb\u52a1\u7684\u6808\u5728\u521b\u5efa\u65f6\u9759\u6001\u6307\u5b9a&#xff0c;\u5178\u578b\u4efb\u52a1\u51e0\u767e\u5b57\u8282\u5230\u51e0 KB\u3002TCP\/IP \u534f\u8bae\u6808\u4efb\u52a1\u6216\u8dd1 printf \u7684\u4efb\u52a1\u53ef\u80fd\u7ed9\u5230 2~4KB&#xff0c;\u4e00\u4e2a\u53ea\u6536\u6d88\u606f\u7684\u5c0f\u4efb\u52a1 128 \u5b57\u8282\u4e5f\u6709\u3002\u4e3a\u4ec0\u4e48\u62a0\u6210\u8fd9\u6837&#xff1f;\u5355\u7247\u673a\u7684\u603b RAM \u672c\u8eab\u5f80\u5f80\u53ea\u6709\u51e0\u5341 KB&#xff0c;\u6808\u662f\u6309\u4efb\u52a1\u6570\u91cf\u500d\u4e58\u7684\u5f00\u9500&#xff0c;8MB \u7684\u5962\u4f88\u60f3\u90fd\u4e0d\u7528\u60f3\u3002<\/p>\n<table>\n<tr>\u4e16\u754c\u5178\u578b\u4e0a\u9650\u4e0a\u9650\u6765\u6e90<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">Linux \u4e3b\u7ebf\u7a0b<\/td>\n<td align=\"left\">8MB&#xff08;\u9ed8\u8ba4&#xff09;<\/td>\n<td align=\"left\">ulimit -s \/ RLIMIT_STACK<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">Linux \u5185\u6838<\/td>\n<td align=\"left\">8~16KB<\/td>\n<td align=\"left\">\u67b6\u6784\u5b9a\u4e49&#xff08;x86-64 \u4e3a 16KB&#xff09;<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">RTOS \u5355\u4efb\u52a1<\/td>\n<td align=\"left\">128B ~ \u51e0 KB<\/td>\n<td align=\"left\">\u521b\u5efa\u4efb\u52a1\u65f6\u9759\u6001\u6307\u5b9a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029152450-6ae36542baf57.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe&#xff1a;\u4e09\u4e2a\u4e16\u754c\u4e09\u79cd\u6808\u4e0a\u9650\u3002\u6570\u91cf\u7ea7\u5dee\u8ddd\u4e00\u76ee\u4e86\u7136&#xff1b;Linux \u7684 8MB \u662f\u4e0a\u9650\u4e0d\u662f\u5b9e\u5360&#xff0c;\u6808\u9875\u6309\u9700\u6302\u8fdb\u9875\u8868\u3002<\/p>\n<h3>\u4e8c\u3001\u7206\u6808\u7684\u4e24\u79cd\u6b7b\u76f8<\/h3>\n<p>\u6808\u5199\u7a7f\u8fb9\u754c\u540e\u53d1\u751f\u4ec0\u4e48&#xff0c;\u53d6\u51b3\u4e8e\u6709\u6ca1\u6709\u4eba\u8bbe\u9632\u3002<\/p>\n<p>\u6709\u8bbe\u9632\u7684\u4e16\u754c\u6b7b\u5f97\u660e\u767d\u3002Linux \u4e3b\u7ebf\u7a0b\u7684\u6808\u533a\u5e26\u5b88\u62a4\u9875&#xff08;guard page&#xff09;&#xff0c;\u8d8a\u754c\u5199\u5165\u843d\u5728\u672a\u6620\u5c04\u9875\u4e0a&#xff0c;MMU \u7ffb\u8bd1\u5931\u8d25&#xff0c;\u8d70\u7bc7 17 \u90a3\u6761\u4e09\u5c42\u5224\u51b3\u6d41\u6c34\u7ebf&#xff0c;SIGSEGV \u73b0\u573a\u5904\u51b3&#xff1b;-fstack-protector \u8fd8\u5728\u6bcf\u5e27\u5b89\u653e canary \u91d1\u4e1d\u96c0\u503c&#xff0c;\u51fd\u6570\u5c3e\u58f0\u53d1\u73b0\u88ab\u6539\u5199\u7acb\u5373\u8c03 __stack_chk_fail \u7ec8\u6b62\u8fdb\u7a0b\u3002\u5e26 MPU \u7684 MCU \u4e5f\u80fd\u505a\u5230\u7c7b\u4f3c\u6548\u679c&#xff1a;\u628a\u4efb\u52a1\u6808\u8fb9\u754c\u8bbe\u4e3a\u4e0d\u53ef\u8bbf\u95ee&#xff0c;\u8d8a\u754c\u7acb\u523b\u89e6\u53d1 fault\u3002\u5d29\u6e83\u96be\u770b&#xff0c;\u4f46\u6b7b\u5728\u6848\u53d1\u73b0\u573a\u3002<\/p>\n<p>\u6ca1\u6709\u8bbe\u9632\u7684\u4e16\u754c\u6b7b\u5f97\u65e0\u58f0\u3002Cortex-M \u88f8\u673a\u6216\u672a\u914d MPU \u7684 RTOS \u4e0a&#xff0c;\u6808\u6307\u9488\u8d8a\u754c\u6ca1\u6709\u4efb\u4f55\u786c\u4ef6\u62e6\u622a&#xff0c;\u5199\u5165\u7ee7\u7eed\u8fdb\u884c&#xff0c;\u8986\u76d6\u7684\u662f\u6070\u597d\u4f4f\u5728\u6808\u65c1\u8fb9\u7684\u5bf9\u8c61&#xff1a;\u522b\u7684\u4efb\u52a1\u7684\u63a7\u5236\u5757\u3001\u5168\u5c40\u53d8\u91cf\u3001\u961f\u5217\u5b58\u50a8\u533a\u3002\u66f4\u7cdf\u7684\u662f\u8fd9\u4e9b\u5bf9\u8c61\u88ab\u7834\u574f\u7684\u65f6\u673a\u5b8c\u5168\u968f\u673a&#xff0c;\u75c7\u72b6\u968f\u4e4b\u6f02\u79fb&#xff1a;\u4eca\u5929\u5d29\u6e83\u5728 A \u4efb\u52a1&#xff0c;\u660e\u5929\u4e32\u53e3\u8f93\u51fa\u4e71\u7801&#xff0c;\u540e\u5929\u914d\u7f6e\u83ab\u540d\u5f52\u96f6\u3002\u8fd9\u7c7b&#034;\u5076\u53d1\u602a\u75c5&#034;\u662f\u5d4c\u5165\u5f0f\u8c03\u8bd5\u7684\u9876\u7ea7\u5669\u68a6&#xff0c;\u771f\u51f6\u7ecf\u5e38\u5c31\u662f\u4e00\u4e2a\u7b97\u5c0f\u4e86\u7684\u4efb\u52a1\u6808\u3002\u8bb0\u4f4f\u8fd9\u4e2a\u5bf9\u6bd4&#xff1a;\u6808\u6ea2\u51fa\u5728\u5e26\u4fdd\u62a4\u7cfb\u7edf\u91cc\u662f\u6bb5\u9519\u8bef&#xff0c;\u5728\u88f8\u7cfb\u7edf\u91cc\u662f\u6162\u6027\u75c5\u3002<\/p>\n<h3>\u4e09\u3001\u6808\u9700\u6c42\u600e\u4e48\u7b97&#xff1a;\u9759\u6001\u4f30\u7b97\u4e0e\u52a8\u6001\u6c34\u4f4d<\/h3>\n<p>\u7b97\u6808\u9700\u6c42\u6709\u4e24\u6761\u4e92\u8865\u7684\u8def\u3002<\/p>\n<p>\u9759\u6001\u4f30\u7b97\u8d70\u7f16\u8bd1\u5668\u3002GCC \u7684 -fstack-usage \u8ba9\u6bcf\u4e2a\u51fd\u6570\u751f\u6210\u4e00\u4e2a .su \u6587\u4ef6&#xff0c;\u8bb0\u5f55\u672c\u51fd\u6570\u4e00\u5e27\u7684\u5b57\u8282\u6570&#xff1b;\u914d -Wstack-usage&#061;N \u53ef\u4ee5\u5bf9\u8d85\u8fc7 N \u5b57\u8282\u7684\u51fd\u6570\u76f4\u63a5\u544a\u8b66\u3002\u5355\u51fd\u6570\u5e27\u5927\u5c0f\u6709\u4e86&#xff0c;\u518d\u6cbf\u8c03\u7528\u56fe\u627e\u6700\u6df1\u8def\u5f84\u9010\u5c42\u6c42\u548c&#xff0c;\u5c31\u662f\u6700\u574f\u60c5\u51b5\u7684\u9759\u6001\u6808\u6df1\u3002\u9012\u5f52\u662f\u8fd9\u6761\u8def\u7684\u5929\u654c&#xff08;\u6df1\u5ea6\u4e0d\u5b9a&#xff09;&#xff0c;\u9047\u5230\u53ea\u80fd\u6309\u6700\u5927\u6df1\u5ea6\u4e58\u6bcf\u5c42\u5e27\u5927\u5c0f\u4f30\u7b97&#xff0c;\u6216\u5e72\u8106\u7981\u6b62\u9012\u5f52\u3002RTOS \u5de5\u7a0b\u91cc&#xff0c;-fstack-usage \u5ba1\u8ba1 &#043; \u7ea2\u7ebf\u544a\u8b66\u662f\u5165\u804c\u65b0\u9879\u76ee\u7684\u5e38\u89c4\u4f53\u68c0\u3002<\/p>\n<p>\u52a8\u6001\u6d4b\u91cf\u8d70\u6c34\u4f4d\u3002FreeRTOS \u521b\u5efa\u4efb\u52a1\u65f6\u7528 0xA5 \u586b\u6ee1\u4efb\u52a1\u6808&#xff0c;\u8fd0\u884c\u4e2d\u88ab\u8986\u76d6\u7684\u533a\u57df\u5c31\u662f\u771f\u5b9e\u89e6\u8fbe\u8fc7\u7684\u90e8\u5206&#xff1b;uxTaskGetStackHighWaterMark() \u8fd4\u56de\u5386\u53f2\u6700\u4f4e\u5269\u4f59\u91cf&#xff08;\u5355\u4f4d\u4e3a\u6808\u5b57 StackType_t&#xff09;&#xff0c;&#034;\u6c34\u4f4d&#034;\u8d8a\u4f4e\u8bf4\u660e\u6808\u8d8a\u63a5\u8fd1\u7528\u6ee1\u3002\u5de5\u7a0b\u60ef\u4f8b\u662f\u8ba9\u6ee1\u8f7d\u8dd1\u591f\u957f\u65f6\u95f4&#xff0c;\u6c34\u4f4d\u903c\u8fd1 0 \u5373\u7206\u6808\u524d\u5146&#xff1b;\u5b9a\u4efb\u52a1\u6808\u5927\u5c0f\u65f6\u5728\u89c2\u6d4b\u5cf0\u503c\u4e0a\u7559 30%~50% \u7684\u88d5\u91cf&#xff08;\u7ecf\u9a8c\u503c&#xff0c;\u968f\u4efb\u52a1\u5173\u952e\u5ea6\u52a0\u7801&#xff09;\u3002Linux \u4fa7\u53e6\u6709 ulimit -s \u7684\u4e0a\u9650\u6982\u5ff5&#xff0c;\u4f46\u90a3\u662f\u914d\u989d\u4e0d\u662f\u7528\u91cf&#xff0c;\u5b9e\u9645\u7528\u91cf\u8981\u9760\u6808\u56de\u6eaf\u6216\u63d2\u6869\u7edf\u8ba1\u3002<\/p>\n<p>\u4e24\u6cd5\u5408\u7528&#xff1a;\u9759\u6001\u4f30\u7b97\u7ed9\u51fa\u8bbe\u8ba1\u503c&#xff08;\u5199\u8fdb\u4efb\u52a1\u521b\u5efa\u4ee3\u7801&#xff09;&#xff0c;\u52a8\u6001\u6c34\u4f4d\u7ed9\u51fa\u9a8c\u8bc1\u503c&#xff08;\u91cf\u4ea7\u524d\u7684\u6d4b\u8bd5\u9879&#xff09;&#xff0c;\u7f3a\u4e00\u4e0d\u53ef\u3002<\/p>\n<h3>\u56db\u3001\u9632\u7206\u4e09\u9053\u95f8<\/h3>\n<p>\u7b2c\u4e00\u9053\u95f8&#xff0c;\u9759\u6001\u95f8&#xff1a;\u8bbe\u8ba1\u671f\u5c31\u628a\u98ce\u9669\u62d2\u4e4b\u95e8\u5916\u3002\u9012\u5f52\u8981\u4e48\u8bbe\u6df1\u5ea6\u4e0a\u9650\u3001\u8981\u4e48\u6539\u8fed\u4ee3&#xff1b;\u5927\u5c40\u90e8\u6570\u7ec4&#xff08;\u6bd4\u5982\u90a3\u4e2a char buf[8*1024*1024]&#xff09;\u6539\u9759\u6001\u5206\u914d\u6216\u8d70\u5806&#xff1b;-Wstack-usage \u8bbe\u7ea2\u7ebf&#xff0c;\u8d85\u6807\u51fd\u6570\u8fc7\u4e0d\u4e86\u7f16\u8bd1\u5ba1\u67e5\u3002\u6bcf\u4e2a\u65b0\u589e\u51fd\u6570\u5728 .su \u6587\u4ef6\u91cc\u7559\u75d5&#xff0c;\u6808\u8d26\u76ee\u968f\u4ee3\u7801\u4e00\u8d77\u8fdb\u7248\u672c\u7ba1\u7406\u3002<\/p>\n<p>\u7b2c\u4e8c\u9053\u95f8&#xff0c;\u8fd0\u884c\u95f8&#xff1a;\u8ba9\u8d8a\u754c\u5728\u7b2c\u4e00\u65f6\u95f4\u88ab\u53d1\u73b0\u3002FreeRTOS \u6253\u5f00 configCHECK_FOR_STACK_OVERFLOW&#061;2&#xff0c;\u540c\u65f6\u505a\u4e24\u9879\u6821\u9a8c&#xff1a;\u6808\u6307\u9488\u662f\u5426\u8d8a\u754c &#043; \u6808\u5e95 0xA5 \u586b\u5145\u56fe\u6848\u662f\u5426\u88ab\u7834\u574f&#xff0c;\u4e00\u65e6\u786e\u8ba4\u6ea2\u51fa\u8fdb\u5165 vApplicationStackOverflowHook() \u94a9\u5b50&#xff0c;\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u8bb0\u5f55\u4efb\u52a1\u540d\u3001\u6253\u70b9\u3001\u590d\u4f4d&#xff0c;\u628a&#034;\u968f\u673a\u62bd\u98ce&#034;\u53d8\u6210&#034;\u786e\u5b9a\u6027\u62a5\u8b66&#034;\u3002\u684c\u9762\u4fa7\u7684\u7b49\u4ef7\u7269\u662f -fstack-protector \u7684 canary\u3002<\/p>\n<p>\u7b2c\u4e09\u9053\u95f8&#xff0c;\u786c\u4ef6\u95f8&#xff1a;\u628a\u8fb9\u754c\u4ea4\u7ed9 MPU\u3002\u5e26 MPU \u7684 MCU \u53ef\u4ee5\u628a\u6bcf\u4e2a\u4efb\u52a1\u6808\u7684\u8fb9\u754c\u533a\u57df\u8bbe\u4e3a\u4e0d\u53ef\u8bbf\u95ee&#xff0c;\u8d8a\u754c\u8bbf\u95ee\u5f53\u573a\u89e6\u53d1 fault&#xff0c;\u8fdb\u5165\u786c\u9519\u8bef\u5904\u7406&#xff0c;\u8fd9\u662f\u88f8\u673a\u4e16\u754c\u80fd\u62ff\u5230\u7684\u6700\u5f3a\u9632\u7ebf&#xff0c;\u7b49\u4e8e\u7ed9\u6bcf\u4e2a\u4efb\u52a1\u914d\u4e0a\u4e86 Linux \u4e3b\u7ebf\u7a0b\u624d\u6709\u7684\u5b88\u62a4\u9875\u3002\u4e09\u9053\u95f8\u4ece\u4fbf\u5b9c\u5230\u8d35\u3001\u4ece\u8bbe\u8ba1\u671f\u5230\u8fd0\u884c\u671f&#xff0c;\u6309\u9879\u76ee\u8d44\u6e90\u4f9d\u6b21\u53e0\u4e0a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029152451-6ae3654364623.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u56fe&#xff1a;\u7206\u6808\u7684\u4e24\u79cd\u6b7b\u76f8\u4e0e\u9632\u7206\u4e09\u9053\u95f8\u3002\u9759\u6001\u95f8\u5728\u8bbe\u8ba1\u671f\u62d2\u9669&#xff0c;\u8fd0\u884c\u95f8\u8ba9\u8d8a\u754c\u786e\u5b9a\u6027\u62a5\u8b66&#xff0c;\u786c\u4ef6\u95f8\u628a\u8fb9\u754c\u4ea4\u7ed9 MPU\u3002<\/p>\n<h3>\u5199\u5728\u6700\u540e<\/h3>\n<li>\u6808\u4e0a\u9650\u4e09\u4e2a\u4e16\u754c\u4e09\u6863\u6570\u5b57&#xff1a;Linux \u4e3b\u7ebf\u7a0b\u9ed8\u8ba4 8MB&#xff08;ulimit -s&#xff0c;\u6808\u9875\u6309\u9700\u589e\u957f&#xff09;\u3001\u5185\u6838\u6808 8~16KB&#xff08;\u7981\u5927\u6570\u7ec4\u7981\u6df1\u9012\u5f52\u662f\u94c1\u5f8b&#xff09;\u3001RTOS \u5355\u4efb\u52a1\u51e0\u767e\u5b57\u8282&#xff08;\u521b\u5efa\u65f6\u9759\u6001\u6307\u5b9a&#xff09;\u3002<\/li>\n<li>\u7206\u6808\u4e24\u79cd\u6b7b\u76f8&#xff1a;\u6709\u5b88\u62a4\u9875\/canary\/MPU \u7684\u7cfb\u7edf\u6b7b\u5f97\u660e\u767d&#xff08;SIGSEGV\/fault&#xff09;&#xff0c;\u65e0\u4fdd\u62a4\u7684\u7cfb\u7edf\u6084\u6084\u5199\u7a7f\u76f8\u90bb\u5bf9\u8c61&#xff0c;\u75c7\u72b6\u968f\u673a\u6f02\u79fb\u2014\u2014\u5d4c\u5165\u5f0f\u5076\u53d1\u602a\u75c5\u7684\u5e38\u89c1\u771f\u51f6\u3002<\/li>\n<li>\u9700\u6c42\u8ba1\u7b97\u4e24\u8def\u5408\u7528&#xff1a;-fstack-usage \u9759\u6001\u4f30\u7b97\u6700\u6df1\u8c03\u7528\u8def\u5f84 &#043; uxTaskGetStackHighWaterMark() \u52a8\u6001\u6c34\u4f4d\u9a8c\u8bc1&#xff1b;\u5b9a\u6808\u5927\u5c0f\u5728\u5cf0\u503c\u4e0a\u7559 30%~50% \u88d5\u91cf&#xff08;\u7ecf\u9a8c\u503c&#xff09;\u3002<\/li>\n<li>\u9632\u7206\u4e09\u9053\u95f8&#xff1a;\u9759\u6001\u95f8&#xff08;\u7ea2\u7ebf\u544a\u8b66\u3001\u7981\u9012\u5f52\u3001\u5927\u6570\u7ec4\u642c\u5bb6&#xff09;\u3001\u8fd0\u884c\u95f8&#xff08;configCHECK_FOR_STACK_OVERFLOW&#061;2 \u53cc\u91cd\u6821\u9a8c\u8fdb\u94a9\u5b50&#xff09;\u3001\u786c\u4ef6\u95f8&#xff08;MPU \u8fb9\u754c\u4e0d\u53ef\u8bbf\u95ee&#xff09;\u3002<\/li>\n<li>\u9012\u5f52\u662f\u9759\u6001\u4f30\u7b97\u7684\u5929\u654c&#xff0c;\u6df1\u5ea6\u4e0d\u5b9a\u7684\u9012\u5f52\u5728 RTOS \u4e0a\u7b49\u4e8e\u4e0d\u5b9a\u65f6\u70b8\u5f39\u3002<\/li>\n<p>\u6808\u7684\u6781\u9650\u91cf\u5b8c\u4e86&#xff0c;\u4e0b\u4e00\u4e2a\u4e3b\u89d2\u662f\u5806\u3002malloc \u8fd4\u56de\u7684\u6307\u9488\u770b\u8d77\u6765\u5929\u4e0b\u65e0\u654c&#xff0c;\u53ef\u7a0b\u5e8f\u8d8a\u8dd1\u8d8a\u5360\u5185\u5b58\u3001\u91cd\u542f\u624d\u91ca\u653e\u7684\u602a\u8c61\u5c42\u51fa\u4e0d\u7a77\u3002\u4e0b\u4e00\u7bc7\u300amalloc \u4e4b\u540e\u5185\u5b58\u53bb\u54ea\u4e86&#xff1a;\u4e3a\u4f55\u7a0b\u5e8f\u8d8a\u8dd1\u8d8a\u5360\u5185\u5b58\u300b&#xff0c;\u8fdb glibc \u7684\u6279\u53d1\u4ed3\u5e93\u770b chunk\u3001arena \u4e0e RSS \u53ea\u6da8\u4e0d\u964d\u7684\u771f\u76f8\u3002\u540c\u7cfb\u5217\u6587\u7ae0\u4f1a\u9646\u7eed\u53d1\u5e03&#xff0c;\u5173\u6ce8\u540e\u5373\u53ef\u6536\u5230\u66f4\u65b0\u3002<\/p>\n<p>\u56de\u590d\u300c\u4ea4\u6d41\u300d&#xff0c;\u6211\u5f88\u4e50\u610f\u5206\u4eab\u6211\u7684\u5b66\u4e60\u7ecf\u9a8c\u548c\u5de5\u4f5c\u7ecf\u9a8c&#xff0c;\u76f4\u63a5\u6765\u804a\u3002<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\u3002\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u4e0e\u4f5c\u8005\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u731c\u7ed3\u679c\u3002\u8fd9\u6bb5\u5931\u63a7\u9012\u5f52&#xff0c;\u5206\u522b\u5728\u4e24\u4e2a\u5e73\u53f0\u4e0a\u8dd1\u4f1a\u600e\u6837&#xff1f;<br \/>\nvoid recurse(int n) {char pad[4096];       \/* \u6bcf\u5c42\u591a\u5360 4KB *\/recurse(n  1);       \/* \u6ca1\u6709\u51fa\u53e3 *\/<br \/>\n}\u5728 Linux \u4e0a&#xff08;\u4ee5\u9ed8\u8ba4 -O0 \u7f16\u8bd1&#xff1b;\u82e5\u5f00 -O2 \u4ee5\u4e0a\u4f18\u5316&#xff0c;\u8fd9\u4e2a\u5c3e\u9012\u5f52\u4f1a\u88ab\u6539\u5199\u6210\u5faa\u73af&#xff0c;\u6c38\u8fdc\u8dd1\u4e0d\u7206&#xff09;&#xff0c;\u5b83\u8f70\u8f70\u70c8\u70c8\u5730\u6b7b&#xff1a;<\/p>\n","protected":false},"author":2,"featured_media":119558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174,58,219,1363],"topic":[],"class_list":["post-119560","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-linux","tag-219","tag-1363"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/119560.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5148\u731c\u7ed3\u679c\u3002\u8fd9\u6bb5\u5931\u63a7\u9012\u5f52&#xff0c;\u5206\u522b\u5728\u4e24\u4e2a\u5e73\u53f0\u4e0a\u8dd1\u4f1a\u600e\u6837&#xff1f; void recurse(int n) {char pad[4096];    \/* \u6bcf\u5c42\u591a\u5360 4KB *\/recurse(n 1);    \/* \u6ca1\u6709\u51fa\u53e3 *\/ }\u5728 Linux \u4e0a&#xff08;\u4ee5\u9ed8\u8ba4 -O0 \u7f16\u8bd1&#xff1b;\u82e5\u5f00 -O2 \u4ee5\u4e0a\u4f18\u5316&#xff0c;\u8fd9\u4e2a\u5c3e\u9012\u5f52\u4f1a\u88ab\u6539\u5199\u6210\u5faa\u73af&#xff0c;\u6c38\u8fdc\u8dd1\u4e0d\u7206&#xff09;&#xff0c;\u5b83\u8f70\u8f70\u70c8\u70c8\u5730\u6b7b&#xff1a;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119560.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-29T15:24:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029152450-6ae36542baf57.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119560.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119560.html\",\"name\":\"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-29T15:24:52+00:00\",\"dateModified\":\"2026-10-29T15:24:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119560.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119560.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119560.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/119560.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5148\u731c\u7ed3\u679c\u3002\u8fd9\u6bb5\u5931\u63a7\u9012\u5f52&#xff0c;\u5206\u522b\u5728\u4e24\u4e2a\u5e73\u53f0\u4e0a\u8dd1\u4f1a\u600e\u6837&#xff1f; void recurse(int n) {char pad[4096];    \/* \u6bcf\u5c42\u591a\u5360 4KB *\/recurse(n 1);    \/* \u6ca1\u6709\u51fa\u53e3 *\/ }\u5728 Linux \u4e0a&#xff08;\u4ee5\u9ed8\u8ba4 -O0 \u7f16\u8bd1&#xff1b;\u82e5\u5f00 -O2 \u4ee5\u4e0a\u4f18\u5316&#xff0c;\u8fd9\u4e2a\u5c3e\u9012\u5f52\u4f1a\u88ab\u6539\u5199\u6210\u5faa\u73af&#xff0c;\u6c38\u8fdc\u8dd1\u4e0d\u7206&#xff09;&#xff0c;\u5b83\u8f70\u8f70\u70c8\u70c8\u5730\u6b7b&#xff1a;","og_url":"https:\/\/www.wsisp.com\/helps\/119560.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-29T15:24:52+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261029152450-6ae36542baf57.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119560.html","url":"https:\/\/www.wsisp.com\/helps\/119560.html","name":"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-29T15:24:52+00:00","dateModified":"2026-10-29T15:24:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119560.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119560.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119560.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f60\u7684\u6808\u5230\u5e95\u6709\u591a\u5927\uff1a\u7206\u6808\u4e0e\u4efb\u52a1\u6808\u8ba1\u7b97"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=119560"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119560\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/119558"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119560"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}