PHPUnit 分段错误

2022-01-12 00:00:00 segmentation-fault php phpunit

当我的开发盒 (Linux Mint) 上的 PHPUnit 测试正常失败时,它会在我的持续集成盒 (Centos) 上导致分段错误".两台机器都运行相同版本的 PHPUnit.我的开发箱运行 PHP 5.3.2-1ubuntu4.9,CI 是 PHP 5.2.17.不过,我宁愿把升级 PHP 作为最后的手段.

When a PHPUnit test fails normally on my dev box (Linux Mint), it causes a "Segmentation Fault" on my Continous Integration box (Centos). Both machines are running the same version of PHPUnit. My dev box is running PHP 5.3.2-1ubuntu4.9, and the CI is PHP 5.2.17. I'd rather leave upgrading the PHP as a last resort though.

根据这个线程:PHPUnit 得到分段错误我试过停用/重新安装 Xdebug.我没有安装 inclue.so.

As per this thread: PHPUnit gets segmentation fault I have tried deactivating / reinstalling Xdebug. I don't have inclue.so installed.

在 CI 框上,我目前只有两个处于活动状态的扩展:来自 php-xml 的 dom(phpunit 需要)和 memcache(我的框架需要),所有其他的都已关闭.

On the CI box I currently only have two extensions active: dom from php-xml (required for phpunit) and memcache (required by my framework), all the others have been turned off.

推荐答案

在 cweiske 建议的旁边,如果升级 PHP 不是您的选择,并且您在定位 segfault 的来源时遇到问题,您可以使用调试器来了解更多.

Next to what cweiske suggested, if upgrading PHP is not an option for you and you have problems to locate the source of the segfault, you can use a debugger to find out more.

您可以通过这种方式启动 gdb 来调试 PHPUnit 会话:

You can launch gdb this way to debug a PHPUnit session:

gdb --args php /usr/bin/phpunit quiz_service_Test.php

然后输入 r 以运行程序和/或首先设置环境变量.

Then type in r to run the program and/or set environment variables first.

set env MALLOC_CHECK_=3
r

您也可以考虑在系统上安装 PHP 的调试符号以获得更好的调试结果.gdb 会在启动时为您检查这一点,并通知您如何执行此操作.

You might also consider to install the debugging symbols for PHP on the system to get better results for debugging. gdb checks this on startup for you and leaves a notice how you can do so.

相关文章