[轉]Linux的棧大小限制- -

Linux的棧大小限制- -

                                      

 

8M,具體的方法如下:
#include <stdio.h>
int main(int argc, char *argv[])
{
 int buf[2*1024*1024];
 printf("Hello,world");
 return 0;
}
運行的時候會SegmentationFault
用GDB調試
08048460 <main>:
 8048460: 55                    push   %ebp
 8048461: 89 e5                 mov    %esp,%ebp
 8048463: 81 ec c8 e0 7f 00     sub    $0x7fe0c8,%esp
 8048469: 83 ec 0c              sub    $0xc,%esp
 804846c: 68 e8 84 04 08        push   $0x80484e8
 8048471: e8 c6 fe ff ff        call   804833c <_init+0x58>
 8048476: 83 c4 10              add    $0x10,%esp
 8048479: b8 00 00 00 00        mov    $0x0,%eax
 804847e: c9                    leave 
 804847f: c3                    ret   
出錯的時候,程序停在804846c上,也就是說無法PUSH,此時的ESP已經超出了正常的堆棧範圍,最後得出的結論:Linux的棧大小是8M,不過是2.4.7內核,不知道別的內核是不是這個樣子 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章