php - Laravel 5 项目导致 PHP/Apache 崩溃

标签 php debugging laravel

我们更新了 Ubuntu 14.04 服务器上的 Laravel 5 项目,现在访问其主页时出现 ERR_EMPTY_RESPONSE 错误。

服务器上的其他 PHP 应用程序工作正常。

使用 GDB,我们能够生成以下内容:

root@server-3 /var/crash/apache # gdb apache2 -core CoreDump
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 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-linux-gnu".
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 apache2...Reading symbols from /usr/lib/debug//usr/sbin/apache2...done.
done.
[New LWP 27190]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20121212/mysql.so" does not match "/usr/lib/php5/20121212/mysql.so" (CRC mismatch).


warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20121212/mysql.so" does not match "/usr/lib/php5/20121212/mysql.so" (CRC mismatch).


warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20121212/mysqli.so" does not match "/usr/lib/php5/20121212/mysqli.so" (CRC mismatch).


warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20121212/mysqli.so" does not match "/usr/lib/php5/20121212/mysqli.so" (CRC mismatch).


warning: the debug information found in "/usr/lib/debug//usr/lib/php5/20121212/pdo_mysql.so" does not match "/usr/lib/php5/20121212/pdo_mysql.so" (CRC mismatch).


warning: the debug information found in "/usr/lib/debug/usr/lib/php5/20121212/pdo_mysql.so" does not match "/usr/lib/php5/20121212/pdo_mysql.so" (CRC mismatch).

Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  zend_parse_parameters (num_args=1, type_spec=type_spec@entry=0x7f8b02987f9a "H") at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_API.c:924
924 /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_API.c: No such file or directory.

输入backtrace后:

#0  zend_parse_parameters (num_args=1, type_spec=type_spec@entry=0x7f8b02987f9a "H") at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_API.c:924
#1  0x00007f8b024440bf in zif_end (ht=<optimized out>, return_value=0x7f8b09329c60, return_value_ptr=<optimized out>, this_ptr=<optimized out>, return_value_used=1)
    at /build/php5-RpYHCf/php5-5.5.9+dfsg/ext/standard/array.c:822
#2  0x00007f8b0251700b in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:97
#3  0x00007f8b025d7075 in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:552
#4  0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b09317418) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#5  0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#6  0x00007f8b025d76c0 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f8b093172c8) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#7  0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b093172c8) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#8  0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#9  0x00007f8b025d76c0 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f8b09317158) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#10 0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b09317158) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#11 0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#12 0x00007f8b025d76c0 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f8b09317020) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#13 0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b09317020) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#14 0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#15 0x00007f8b025d76c0 in zend_do_fcall_common_helper_SPEC (execute_data=0x7f8b09316f20) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:584
#16 0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b09316f20) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#17 0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#18 0x00007f8b02519241 in zend_call_function (fci=fci@entry=0x7fffc06b8a50, fci_cache=<optimized out>, fci_cache@entry=0x7fffc06b8a20) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_execute_API.c:939
#19 0x00007f8b0253e1e5 in zend_call_method (object_pp=object_pp@entry=0x7fffc06b8b08, obj_ce=<optimized out>, obj_ce@entry=0x7f8b08bae380, fn_proxy=fn_proxy@entry=0x0, 
    function_name=function_name@entry=0x7f8b02973648 "offsetget", function_name_len=function_name_len@entry=9, retval_ptr_ptr=retval_ptr_ptr@entry=0x7fffc06b8b18, param_count=param_count@entry=1, 
    arg1=arg1@entry=0x7f8b09329c10, arg2=arg2@entry=0x0) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_interfaces.c:97
#20 0x00007f8b02549725 in zend_std_read_dimension (object=0x7f8b08b270d0, offset=0x7f8b09329c10, type=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_object_handlers.c:646
#21 0x00007f8b025ad250 in zend_fetch_dimension_address_read (result=0x7f8b09316e10, container=0x7f8b08b270d0, dim=<optimized out>, dim_type=dim_type@entry=1, type=type@entry=0)
    at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_execute.c:1332
#22 0x00007f8b025ae66c in ZEND_FETCH_DIM_R_SPEC_CV_CONST_HANDLER (execute_data=0x7f8b09316e30) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:32192
#23 0x00007f8b02550da8 in execute_ex (execute_data=0x7f8b09316e30) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_vm_execute.h:363
#24 0x00007f8b02516f09 in dtrace_execute_ex (execute_data=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:73
#25 0x00007f8b02519241 in zend_call_function (fci=fci@entry=0x7fffc06b8e40, fci_cache=<optimized out>, fci_cache@entry=0x7fffc06b8e10) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_execute_API.c:939
#26 0x00007f8b0244c729 in zif_call_user_func (ht=<optimized out>, return_value=0x7f8b09329a80, return_value_ptr=<optimized out>, this_ptr=<optimized out>, return_value_used=<optimized out>)
    at /build/php5-RpYHCf/php5-5.5.9+dfsg/ext/standard/basic_functions.c:4781
#27 0x00007f8b0251700b in dtrace_execute_internal (execute_data_ptr=<optimized out>, fci=<optimized out>, return_value_used=<optimized out>) at /build/php5-RpYHCf/php5-5.5.9+dfsg/Zend/zend_dtrace.c:97

等等...

如何修复/进一步调试此问题? Google 没有为此提出任何具体的 PHP 错误,也许我真的不知道要搜索什么。

有没有办法在 PHP 代码中找到呕吐行?

最佳答案

通过一些 git bisect 魔法,我能够识别一个包含对配置文件中的 url() 调用的提交 (config子文件夹)。这导致了递归。

在我的开发机器上,我收到错误达到最大函数嵌套级别“100”,正在中止!。在定制服务器上,我刚刚遇到 PHP 崩溃。

我能够通过这样的递归重现 PHP 崩溃:

<?php

function foo() {
    foo();
}
foo();

我不知道消息“已达到最大函数嵌套级别‘100’,正在中止!”来自XDEBUG,当然服务器上没有启用它。

所以 PHP 在递归时崩溃是正常行为。

关于php - Laravel 5 项目导致 PHP/Apache 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32742038/

相关文章:

java - Eclipse 在单独的窗口中打开代码

c# - 如何判断应用程序是否正在调试

iphone - 为 iPhone 模拟器构建时,XCode 控制台中不再有 gdb

php - 如何处理 Laravel Eloquent "WHERE"Query with slash on the value? (拉拉维尔 5.3)

php - 如何将文本写入 XML 文件?

php - 如何选择这个表?

php - PHP 的 C++ 扩展

php - InnoDB 未提交但已写入(使用带有动态函数名的 PHP)

php - Laravel Blade : Increment variable by 1 each time?

php - laravel v4.2 中 Redis 服务器连接错误