I am debugging an application during which I encountered a runtime error in a module for which I don't have symbols. I looked into the assembly code for it and have identified the code line which is throwing the EXC_BAD_ACCESS error:
0x7fff204dd0a5 <+37>: movq %rdx, %rcx
0x7fff204dd0a8 <+40>: cld
-> 0x7fff204dd0a9 <+41>: rep movsb (%rsi), %es:(%rdi)
0x7fff204dd0ab <+43>: popq %rbp
Assembly instructions one frame below:
0x10c2641b0 <+96>: callq 0x10c264382 ; symbol stub for: memcpy
-> 0x10c2641b5 <+101>: movl $0x0, -0x4(%rbp)
0x10c2641bc <+108>: movl -0x4(%rbp), %eax
The lines marked with an arrow are throwing the error. I am very new to assembly language and am not able to figure out why this error is being thrown.
As far as I understand, movl instruction moves 32 bits of data from the second variable into the first. Is the error being thrown because $0x0 is a null address? I am not sure because $ indicates a variable and not a constant
Edit: I got to know that rsi and rdi are source and destination index registers and they are specially used for memcpy implementation. I was able to read the values of these registers. It turns out there is access violation reading the value at address of rsi register. Does this mean that source memory is getting corrupted? What are the possible reasons for this to happen?