I have an MPI application with which combines both C and Fortran sources. Occasionally it crashes due to a memory related bug, but I am having trouble finding the bug (it is somewhere in someone else's code, which at the moment I'm not very familiar with). I haven't yet been able to catch it with gdb, but sometimes a glibc backtrace is output as shown below.
The bug is probably close to "(main_main_+0x3bca)[0x804d5ce]", (but with a memory error, I know this may not be the case). My question is, does anyone know how to convert +0x3bca or 0x804d5ce into a particular line of the code?
Any other suggestions on tracking down the bug would also be appreciated. I'm quite familiar with the basics of gdb.
*** glibc detected *** /home/.../src/finite_element: munmap_chunk(): invalid pointer: 0x09d83018 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x73e42)[0xb7409e42]
/lib/i386-linux-gnu/libc.so.6(+0x74525)[0xb740a525]
/home/.../src/finite_element(main_main_+0x3bca)[0x804d5ce]
/home/.../src/finite_element[0x804e195]
/home/.../src/finite_element(main+0x34)[0x804e1e8]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb73af4d3]
/home/davepc/finite-element/src/finite_element[0x8049971]
======= Memory map: ========
08048000-08056000 r-xp 00000000 08:05 1346306 /home/.../src/finite_element
08056000-08057000 r--p 0000d000 08:05 1346306 /home/.../src/finite_element
08057000-08058000 rw-p 0000e000 08:05 1346306 /home/.../src/finite_element
09d1b000-09d8f000 rw-p 00000000 00:00 0 [heap]
b2999000-b699b000 rw-s 00000000 08:03 15855 /tmp/openmpi-sessions-_0/37612/1/shared_mem_pool.babel
b699b000-b6b1d000 rw-p 00000000 00:00 0
b6b31000-b6b3d000 r-xp 00000000 08:03 407798 /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
b6b3d000-b6b3e000 r--p 0000b000 08:03 407798 /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
b6b3e000-b6b3f000 rw-p 0000c000 08:03 407798 /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
<snip>
Thank you...
The backtrace function obtains a backtrace for the current thread, as a list of pointers, and places the information into buffer . The argument size should be the number of void * elements that will fit into buffer . The return value is the actual number of entries of buffer that are obtained, and is at most size .
To print a backtrace of the entire stack, use the backtrace command, or its alias bt . This command will print one line per frame for frames in the stack. By default, all stack frames are printed. You can stop the backtrace at any time by typing the system interrupt character, normally Ctrl-c .
If you are in gdb
and you have debugging symbols, it is quite easy. Use list
.
(gdb) list *0x804d5ce
This should give you the line of code, and show you the source if it is able to find the source file.
Without gdb
you could try to use addr2line
:
$ addr2line -e finite_element 0x804d5ce
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With