(My environment is 64-bit Ubuntu, my application is C++ compiled and linked with g++.)
When an application does something like divide by zero or run a asm("int $3")
left in the code, one of the following gets logged via syslog to /var/log/kern.log
and /var/log/messages
:
Sep 10 18:06:47 VM kernel: [117194.123452] a.out[20288] trap divide error ip:45c59d sp:7fff65a91810 error:0 in a.out[400000+144000]
Sep 10 18:07:10 VM kernel: [117217.020833] a.out[20294] trap int3 ip:45c493 sp:7fff5cc559f0 error:0
In both those cases, the instruction pointer address points to something that I can easily look up in the .map
file produced at link time (using the "-Wl,-Map,output.map
").
But if I cause a seg fault, in this case by a call to memcpy()
with the source set to NULL, the instruction pointer is so out of range, I have no idea how it is supposed to be mapped:
Sep 10 18:06:13 VM kernel: [117160.228587] a.out[20282]: segfault at 0 ip 00007f7e79209092 sp 00007fff831faf08 error 4 in libc-2.9.so[7f7e79185000+168000]
In this example, I would have expected the IP to be in the range of 0x445e70-0x445e7f, which is the location of memcpy() according to my .map file.
My question: What is the trick to interpreting the ip in this case?