mardi 4 août 2015

Strange segmentation fault in x86 assembly

While I'm debugging a segmentation fault in x86-Linux, I've ran into this problem:

Here goes the seg-fault message from the GDB

0xe2a5a99f in my_function (pSt=pSt@entry=0xe1d09000, version=43)

Here goes the faulting assembly:

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

As you can see above, the faulting line is "call get_pc_thunk" which is just getting the pc value. And, I checked the memory at 0xe29966cb is valid and accessible with the following command:

(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    

Which looks perfectly fine. But Strangely, if I use "si" to step into the "get_pc_thunk" function, it seg-faults without even entering the first nop.

Any help would be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire