[英]Strange segmentation fault in x86 assembly
当我在x86-Linux中调试分段错误时,我遇到了这个问题:
这是来自GDB的seg-fault消息
0xe2a5a99f in my_function (pSt=pSt@entry=0xe1d09000, version=43)
这是故障组件:
0xe2a5a994 <my_function> push %ebp
0xe2a5a995 <my_function+1> push %edi
0xe2a5a996 <my_function+2> push %esi
0xe2a5a997 <my_function+3> push %ebx
0xe2a5a998 <my_function+4> lea -0x100b0c(%esp),%esp
0xe2a5a99f <my_function+11> call 0xe29966cb <__x86.get_pc_thunk.bx>
0xe2a5a9a4 <my_function+16> add $0x9542c,%ebx
正如您在上面所看到的,错误行是“call get_pc_thunk”,它只是获取pc值。 并且,我检查了0xe29966cb的内存是否有效并可通过以下命令访问:
(gdb) x/10i 0xe29966cb
0xe29966cb <__x86.get_pc_thunk.bx>: nop
0xe29966cc <__x86.get_pc_thunk.bx+1>: nop
0xe29966cd <__x86.get_pc_thunk.bx+2>: nop
0xe29966ce <__x86.get_pc_thunk.bx+3>: nop
0xe29966cf <__x86.get_pc_thunk.bx+4>: nop
0xe29966d0 <__x86.get_pc_thunk.bx+5>: nop
0xe29966d1 <__x86.get_pc_thunk.bx+6>: nop
0xe29966d2 <__x86.get_pc_thunk.bx+7>: nop
0xe29966d3 <__x86.get_pc_thunk.bx+8>: mov (%esp),%ebx
0xe29966d6 <__x86.get_pc_thunk.bx+11>: ret
哪个看起来很好。 但奇怪的是,如果我使用“si”进入“get_pc_thunk”函数,它甚至不会进入第一个nop就会出现错误。
任何帮助,将不胜感激。
CALL
(或PUSH
, MOV (%esp)
)指令崩溃几乎总是由于堆栈溢出。
检查程序是否有无限(或非常深)的递归。
这个:
0xe2a5a998 <my_function+4> lea -0x100b0c(%esp),%esp
表示my_function
为当前堆栈帧分配略超过1MB的局部变量。 而现在你知道为什么这可能不是一个好主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.