PHP中的分段错误(核心转储)


Segmentation fault (core dumped) in PHP

好吧,我在Ubuntu的命令行上运行一个PHP应用程序,它以"Segmentation fault(core dumped)"结束。

我该如何从这里调试它?我确信没有内存泄漏,因为我已经用get_memory_usage()检查过了。

编辑:好的,正如Brendan和Ulricht所解释的,我尝试了gdb。这根本不是我的环境,所以对即将到来的新手问题感到抱歉。

我在gdb下运行了代码,得到了segfault。这是前22行。

(gdb) bt
#0  0x00000000006f5d36 in ?? ()
#1  0x00000000006f7625 in ?? ()
#2  0x00000000006f7b68 in zend_parse_parameters ()
#3  0x0000000000610584 in zif_array_rand ()
#4  0x00000000006dd9bb in dtrace_execute_internal ()
#5  0x000000000079da15 in ?? ()
#6  0x0000000000717748 in execute_ex ()
#7  0x00000000006dd8b9 in dtrace_execute_ex ()
#8  0x000000000079e060 in ?? ()
#9  0x0000000000717748 in execute_ex ()
#10 0x00000000006dd8b9 in dtrace_execute_ex ()
#11 0x000000000079e060 in ?? ()
#12 0x0000000000717748 in execute_ex ()
#13 0x00000000006dd8b9 in dtrace_execute_ex ()
#14 0x000000000079e060 in ?? ()
#15 0x0000000000717748 in execute_ex ()
#16 0x00000000006dd8b9 in dtrace_execute_ex ()
#17 0x000000000079e060 in ?? ()
#18 0x0000000000717748 in execute_ex ()
#19 0x00000000006dd8b9 in dtrace_execute_ex ()
#20 0x000000000079e060 in ?? ()
#21 0x0000000000717748 in execute_ex ()
#22 0x00000000006dd8b9 in dtrace_execute_ex ()

根据https://bugs.php.net/bugs-generating-backtrace.php,我应该得到"execute"调用,而不是"execute_ex"。同样的事情?

以下命令无论如何都不会返回函数名称(在完成第6帧之后):

print (char *)(executor_globals.function_state_ptr->function)->common.function_name
Attempt to extract a component of a value that is not a structure.

伊迪丝2:我很高兴知道为什么投了反对票。我认为这是一个有效的问题,我还没有为PHP找到类似的问题。如果有,你可以自由评论。

有几件事可以确定错误,但第一件事是在gdb:中运行可执行文件

> gdb /usr/bin/php
....
(gdb) run path/to/script

请注意,您还可以将转储的核心加载到gdb中。找出问题原因的其他工具还有strace和valgrind。