tideways/php-xhprof-extension

Segfault using v5.0-beta1

Closed this issue · 6 comments

I used to compile v5.0-beta1 in Alpine docker container - PHP 7.1.14

Tested small scripts - works fine!

But once I started to profile Drupal I got segfault (not yet found how to get what is caused it)
The integration I'm working on is https://www.drupal.org/project/xhprof/issues/2945687

@andypost thanks for the report. can you check the syslog in the container with the segfault line? it should be something along the lines of php-fpm[32649]: segfault at 8 ip 00007f3d6192e84e sp 00007fff068fac90 error 4 in tideways_xhprof.so[7f3d61928000+18000]. if you have this, you can calculate the file+line or address in the objdump of the shared address where the segfault happend. I just need the line from you, then i can give you back more commands for debugging.

Other approach would be to install gdb into the container, modify php-fpm to generate core dumps and then analyze that, its a bit more work though and if you haven't done it before it will be quite tricky :)

Thanx for quick reply, checking
php_1 | [20-Feb-2018 19:21:46] WARNING: [pool app] child 9 exited on signal 11 (SIGSEGV - core dumped) after 15.137710 seconds from start

diggin how to get coredump in docker)

# echo '/tmp/coredump-%e.%p' > /proc/sys/kernel/core_pattern
ash: can't create /proc/sys/kernel/core_pattern: Read-only file system

Setting on host helped according guide and then I got it
https://ma.ttias.be/generate-php-core-dumps-segfaults-php-fpm/

@47172edfb79d:/tmp$ gdb /usr/sbin/php-fpm7 core.47172edfb79d.php-fpm7.1519158010 
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/php-fpm7...(no debugging symbols found)...done.
[New LWP 359]

warning: Can't read pathname for load map: No error information.
Core was generated by `php-fpm: pool app                      '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  tracing_callgraph_bucket_find (bucket=0x2, current_frame=current_frame@entry=0x7f22476e19b0, previous=previous@entry=0x7f22476e1960, key=key@entry=4720297052383811517)
    at /srv/php-xhprof-extension-5.0-beta1/tracing.c:95
95	/srv/php-xhprof-extension-5.0-beta1/tracing.c: No such file or directory.

And now I got line tracing.c:95
kinda related? #45

Reading symbols from /usr/sbin/php-fpm7...(no debugging symbols found)...done.
[New LWP 359]

warning: Can't read pathname for load map: No error information.
Core was generated by `php-fpm: pool app                      '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  tracing_callgraph_bucket_find (bucket=0x2, current_frame=current_frame@entry=0x7f22476e19b0, previous=previous@entry=0x7f22476e1960, key=key@entry=4720297052383811517)
    at /srv/php-xhprof-extension-5.0-beta1/tracing.c:95
95	        if (bucket->key == key &&

FYI I did build extension from master branch & looks it works fine! probably it's time to release second beta)

@andypost thank you, sorry so much :-( tagged a new version on master.