I've followed the instructions of the somewhat similar SO question, but the line I get doesn't make sense.
I've an apache process running php compiled with a custom c php extension. Occasionally I'm getting a segmentation fault and a core dump.
This is running on an up to date RHEL 6.5 server.
I've installed the debuginfo rpm for our php extension. Opening the core and getting the bt gives me
(gdb) bt
#0 0x00007f7d7b99dd2f in ?? () from /etc/httpd/modules/libphp5.so
#1 0x00007f7d74783c81 in zif_x12_parse_file () from /usr/lib64/php/modules/x12_parser.so
#2 0x00007f7d7ba093b8 in ?? () from /etc/httpd/modules/libphp5.so
#3 0x00007f7d7b9e0500 in execute () from /etc/httpd/modules/libphp5.so
#4 0x00007f7d7b9ba70d in zend_execute_scripts () from /etc/httpd/modules/libphp5.so
#5 0x00007f7d7b968798 in php_execute_script () from /etc/httpd/modules/libphp5.so
#6 0x00007f7d7ba43d75 in ?? () from /etc/httpd/modules/libphp5.so
#7 0x00007f7d864b4bb0 in ap_run_handler ()
#8 0x00007f7d864b846e in ap_invoke_handler ()
#9 0x00007f7d864c3b30 in ap_process_request ()
#10 0x00007f7d864c09a8 in ?? ()
#11 0x00007f7d864bc6b8 in ap_run_process_connection ()
#12 0x00007f7d864c8977 in ?? ()
#13 0x00007f7d864c8c8a in ?? ()
#14 0x00007f7d864c8fbb in ap_mpm_run ()
#15 0x00007f7d864a0900 in main ()
I’m assuming that the problem is actually in our code, not php at the top of the stack. So I get the location the so is loaded with
(gdb) info shared x12
From To Syms Read Shared Object Library
0x00007f7d7477ec20 0x00007f7d74784038 Yes /usr/lib64/php/modules/x12_parser.so
Subtracting the load start location from stack memory location
0x00007f7d74783c81 − 0x00007f7d7477ec20 = 5061
And punching that into addr2line
$ addr2line -e /usr/lib/debug/usr/lib64/php/modules/x12_parser.so.debug 0x5061
/usr/src/debug/php-x12_parser-5.3.3/php-x12_parser/x12_parser.c:321
But, line 321 isn't in the zif_x12_parse_file. And, even if it was, isn't a line that I imagine could crash.
So what have I done wrong in calculating the line of the crash?
Turned out I was making this way to hard. I simply needed to have the debuginfo rpm installed prior to the crash. Now I get nice back traces.
#0 0x00007fc97334fd2f in ?? () from /etc/httpd/modules/libphp5.so
#1 0x00007fc96c135b3b in zif_x12_parse_file (ht=<value optimized out>,return_value=0x7fc98ec278f8, return_value_ptr=<value optimized out>, this_ptr=<value optimized out>, return_value_used=<value optimized out>) at /usr/src/debug/php-x12_parser-5.3.3/php-x12_parser/x12_parser.c:609
#2 0x00007fc9733bb3b8 in ?? () from /etc/httpd/modules/libphp5.so
#3 0x00007fc973392500 in execute () from /etc/httpd/modules/libphp5.so