每个小时左右一个Apache儿童进程seg。 我们的networking服务器故障。 我们使用Apache prefork MPM运行非线程化的PHP 5.2.17 Apache模块。 我已经运行httpd几个核心转储,gdb和这个.gdbinit文件从PHP的github回购 ,input这个命令到每个gdb:
dump_bt executor_globals.current_execute_data
没有经验的gdb或PHP解释器的内部工作,我不能做任何事情的结果。
core.22762 [0x53896ef0] () :-2118682552 [0x538977a0] () /Statement/Interface.php:113 [0x538978a0] /Zend/Db/Statement/Interface.php() core.22791 [0x538977a0] () @:0 [0x538978a0] () core.5568 [0x53896ef0] () :2061035360 [0x538977a0] () :1767992432 [0x538978a0] () core.30384 [0x538977a0] () :0 [0x538978a0] () core.3091 [0x53896ef0] mysql_query():992424253 [0x538977a0] () ~:17 [0x538978a0] ()
(核心.3091也显示此Program terminated with signal 11, Segmentation fault. )
#0 0x00002b6e7ad8d67d in zend_do_fcall_common_helper_SPEC (execute_data=0x7fff53896ef0) at /usr/src/debug/php-5.2.17/Zend/zend_vm_execute.h:217 217 EX_T(opline->result.u.var).var.fcall_returned_reference = return_reference;
还有什么我可以键入gdb来获得更好的堆栈跟踪? 在debuggingApache分段错误时还有其他的事吗?
任何帮助将不胜感激,谢谢。
我以前见过这个,除了让你的PHP应用程序开发人员检查他们的代码,并确保你有最新版本的PHP和Apache的最新版本,你可以做的不多。
如果您正在运行Op-Code cacher(eaccelerator,APC或XCache),则可以尝试closures它们,这会导致奇怪的段错误。
过去,当然我们不得不为了短期的修复而部署一些令人印象深刻的解决scheme。 例如,这个cronjob运作良好:
# Restart apache when a segfault is found in the most recent line of errorlog #*/5 * * * * tail -n1 /var/log/apache2/error.log | grep 'Segmentation fault' && /etc/init.d/apache2 restart #*/5 * * * * tail -n1 /var/log/apache2/error.log | grep 'Segmentation fault' && /etc/init.d/apache2 restart
或者你可以尝试一些更聪明的东西: #*/5 * * * * /usr/bin/wget http://www.my-site.com/ -T10 -O 2> /dev/null - | grep "Hosted by" > /dev/null || /usr/local/bin/brutally_restart_apache.sh #*/5 * * * * /usr/bin/wget http://www.my-site.com/ -T10 -O 2> /dev/null - | grep "Hosted by" > /dev/null || /usr/local/bin/brutally_restart_apache.sh
在哪里brutally_restart是:
#!/bin/sh /usr/sbin/apache2ctl stop sleep 6 killall -9 apache2 sleep 4 /usr/sbin/apache2ctl start