《coredump问题原理探究》Linux x86版7.12节string coredump

2019-08-01 11:20:02 浏览数 (2)

看一个coredump:

代码语言:javascript复制
Program terminated with signal 11, Segmentation fault.
#0  0x0090bb06 in __strlen_sse2_bsf () from /lib/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6_6.5.i686 libgcc-4.4.7-11.el6.i686 libstdc  -4.4.7-11.el6.i686
(gdb) bt
#0  0x0090bb06 in __strlen_sse2_bsf () from /lib/libc.so.6
#1  0x00cd88b3 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(char const*) () from /usr/lib/libstdc  .so.6
#2  0x080485b7 in main ()

看一下__strlen_sse2_bsf的汇编:

代码语言:javascript复制
(gdb) frame 0
#0  0x0090bb06 in __strlen_sse2_bsf () from /lib/libc.so.6
(gdb) disassemble 
Dump of assembler code for function __strlen_sse2_bsf:
   0x0090baf0 < 0>:  push   %esi
   0x0090baf1 < 1>:  push   �i
   0x0090baf2 < 2>:  mov    0xc(%esp),�i
   0x0090baf6 < 6>:  xor    �x,�x
   0x0090baf8 < 8>:  mov    �i,�x
   0x0090bafa < 10>:  and    $0x3f,�x
   0x0090bafd < 13>:  pxor   %xmm0,%xmm0
   0x0090bb01 < 17>:  cmp    $0x30,�x
   0x0090bb04 < 20>:  ja     0x90bb1d <__strlen_sse2_bsf 45>
=> 0x0090bb06 < 22>:  movdqu (�i),%xmm1
   0x0090bb0a < 26>:  pcmpeqb %xmm1,%xmm0
   0x0090bb0e < 30>:  pmovmskb %xmm0,�x
   0x0090bb12 < 34>:  test   �x,�x
   0x0090bb14 < 36>:  jne    0x90bb89 <__strlen_sse2_bsf 153>
   0x0090bb16 < 38>:  mov    �i,�x
   0x0090bb18 < 40>:  and    $0xfffffff0,�x
   0x0090bb1b < 43>:  jmp    0x90bb37 <__strlen_sse2_bsf 71>
   0x0090bb1d < 45>:  mov    �i,�x

看一下寄存器的值:

代码语言:javascript复制
(gdb) i r edi
edi            0x0  0
(gdb) i r ecx
ecx            0x0  0

0 人点赞