Register has "wrong" value in core dump analyzed by gdb

I am analyzing a core dump file created by SIGSEV using gdb. I get the line number for source C, but when I evaluate the expression, I get the correct value (expression

local_var = ((array[index])->field[index2]).field2 

where arrayis the global variable). The values indexand are index2optimized (of course :-(), but I calculated them a couple of times and every time I got the same valid value. Out of desperation, I checked the parsed code and registers and got the following:

   0x00002b083e06d84c <+142>:   mov    %r13d,%edx          # index (234) to edx
   0x00002b083e06d84f <+145>:   mov    0x2039fa(%rip),%rax # 0x2b083e271250 (address of array)
   0x00002b083e06d856 <+152>:   mov    (%rax,%rdx,8),%rdx  # array[index] (0x2b083e271250+8*234) to rdx
   0x00002b083e06d85a <+156>:   movslq %ecx,%rax           # index2 to rax
=> 0x00002b083e06d85d <+159>:   mov    0x28(%rdx),%rdx     # array[index]->field to rdx

Comments are my understanding of the code. SIGSEV is taken according to the latest instructions. Register contents:

rax            0x5  5
rbx            0x2aaad4096a9c   46913190193820
rcx            0x5  5
rdx            0x0  0
rsi            0xea 234
rdi            0xc75000a9   3343909033
rbp            0x41f898c0   0x41f898c0
rsp            0x41f898a0   0x41f898a0
r8             0x2aaacb411c60   46913042848864
r9             0x2020202020207475   2314885530818475125
r10            0x52203c3c20202020   5917796139299512352
r11            0x2b083bb29070   47314361290864
r12            0xc75000a9   3343909033
r13            0xea 234
r14            0x0  0
r15            0x2aaad40966a4   46913190192804
rip            0x2b083e06d85d   0x2b083e06d85d

rdx 0, , 0x28, . , rdx 0? edx 234 ( r13 , index, ). 8 0x2b083e5b6f20+(8*234)= 0x2b083e5b7670 rdx, 0:

(gdb) x/2 0x2b083e5b7670
0x2b083e5b7670: 0x3e578900  0x00002b08

rdx 0?

x86_64 Linux, . ? SIGSEV .

+3
1

. SIGSEV .

, : , array[index])->field ( 0), ( core).

?

, 99,99% .

+3

All Articles