linux - Mysterious: after mov instruction, destination register %rax did not get expected value (in memory) -


life full of interesting puzzles, wrestling them makes me cackle ...


recently 1 interesting segment fault core dump running instance x86-64 linux in vm (vmware).

mov 0x18(%rdi) %rax // move pointer %rax, trick things happens here                         seems rax did not expected value @ ...// 2 instructions later mov %r8,0x10(%rax)  // load value offset of pointer in memory 

details below.

segment fault dump of assembler code function timer_delink: // function: boolean timer_delink(timer_t *timer), timer cycle link list(prev/next never null)   0x42e0f0 <+0>:     mov    (%rdi),%rcx                       rdi <= timer; rcx <= timer->parent   0x42e0f3 <+3>:     xor    %eax,%eax                         eax <= update_parent <= 0; eax stores return value   0x42e0f5 <+5>:     test   %rcx,%rcx                         if (!timer->parent)  return(false);   0x42e0f8 <+8>:     je     0x42e138 <timer_delink+72>        return eax(update_parent);   0x42e0fa <+10>:    mov    0x18(%rdi),%rax                   rax <= timer->prev             //rax should contain timer->prev,    0x42e0fe <+14>:    mov    0x10(%rdi),%r8                    r8  <= timer->next   0x42e102 <+18>:    mov    0x8(%rcx),%rdx                    rdx <= timer->parent->down =>0x42e106 <+22>:    mov    %r8,0x10(%rax)                    timer->rev->next = timer->next;//info register said rax = 0;   0x42e10a <+26>:    mov    0x10(%rdi),%rsi                   rsi <= timer->next   0x42e10e <+30>:    mov    %rax,0x18(%rsi)                   timer->next->prev = timer->prev;   0x42e112 <+34>:    xor    %eax,%eax                         eax <= update_parent <= 0 

in offending instruction (0x42e106) tries mov %r8's content offset 16 address contained in %rax, caused segment fault

info register said rax = 0, no wonder why segment fault :), .....

  (gdb) info register   rax            0x0      0          ..   rdi            0x20103ff0       ==> stores timer pointer 

but per instruction 0x42e0fa, rax should contain timer->prev, not 0 per memory dump below

(gdb) p *timer     $8 = {parent = 0x2f379e0 <root_timer>, down = 0x0, next = 0x201027c0, prev = 0x20103b28 ...} 

so puzzle is, how content of %rax differs memory on 3rd instruction after mov instruction(0x42e0fa)

could cache issue? race condition?

the context of function call happen in ukernel on top of linux , segment fault happens when ukernel rescheduling threads. 1 hardware cpu thread available.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -