实际的 PHP 代码是否会导致 Apache 中的分段错误?如果是的话,又是如何造成的?

发布于 2024-11-04 01:25:15 字数 1766 浏览 0 评论 0原文

我在 Ubuntu 10.04 x64 上安装了 Apache 2.2.14、PHP 版本 5.3.2 和 libapache2-mod-php5 版本 5.3.2-1ubuntu4.7。我的 apache2 错误日志中经常出现分段错误。在让 Apache 转储崩溃日志并通过 gdb 运行它之后,罪魁祸首似乎是 php 模块。它在特定代码上崩溃。以下是 gdb 的输出:

    Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
0  0x00007ff2b3acaec3 in _zend_mm_free_canary_int (heap=0x7ff2b9035b10, p=0x6d48358fae6de187) at /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c:2090
2090    /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c: No such file or directory.
        in /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c

查看第 0 帧(最内层的帧),结果如下:

(gdb) dump_bt executor_globals.current_execute_data
[0xb79f0c10] get() /var/www/somedirectory/Settingsfile.inc:18
[0xb79f09f0] get() /var/www/somedirectory/securityfile.inc:10
[0xb79ef068] __construct() /var/www/somedirectory/phpfile.php:3

此代码之前在具有 libapache2-mod-php5、PHP 版本 5.2.6 和 Apache 2.2.9 的服务器上运行。我们将所有内容移至运行较新版本的服务器上,并开始收到这些段错误以及用户在尝试访问该网站时间歇性获得空白页面的报告。看起来这两者是相关的,并且段错误是由代码引起的,但我不知道如何开始追踪可能出现的错误,也不知道 PHP 代码实际上是否有可能导致这种情况。我实际上对PHP一无所知,因此没有编写这段代码。所以我的问题是:

  1. 代码实际上是否会导致 Apache 中的分段错误?我是否正确解释了此输出?

  2. 如何调试 PHP 代码?我尝试使用 Firebug 及其配套插件,但它需要比我更多的 Web 编程经验。

  3. 加载到 PHP 本身的模块是否会导致 PHP 模块的功能出现问题?我知道安装了 mod_php5 这就是 Apache 处理 PHP 请求/脚本的方式,但是实际的 PHP5 安装对它的完成方式有什么影响吗?我的意思是我安装了以下内容:

    libapache2-mod-php5 5.3.2-1ubuntu4.7
    PHP5 5.3.2-1ubuntu4.7
    php5-cli 5.3.2-1ubuntu4.7
    php5-common 5.3.2-1ubuntu4.7
    php5-curl 5.3.2-1ubuntu4.7
    php5-mysql 5.3.2-1ubuntu4.7

我不确定它们是如何协同工作的,如果它们确实这样做的话,就像我可以简单地一起卸载 php5 并留下 libapache2-mod-php5 如果这会有所作为的话。

预先感谢您为我提供有关追踪此问题的任何建议。如果您需要 PHP 脚本本身的实际行,我也可以提供。

I have Apache 2.2.14 installed with PHP version 5.3.2 and libapache2-mod-php5 version 5.3.2-1ubuntu4.7 on Ubuntu 10.04 x64. I am getting segmentation faults rather frequently in my apache2 error logs. After getting Apache to dump a crash log and running it through gdb it seems the culprit is the php module. It's crashing on a specific bit of code. Here is the output from gdb:

    Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
0  0x00007ff2b3acaec3 in _zend_mm_free_canary_int (heap=0x7ff2b9035b10, p=0x6d48358fae6de187) at /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c:2090
2090    /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c: No such file or directory.
        in /build/buildd/php5-5.3.2/Zend/zend_alloc_canary.c

A look at frame 0, the innermost frame, yields this:

(gdb) dump_bt executor_globals.current_execute_data
[0xb79f0c10] get() /var/www/somedirectory/Settingsfile.inc:18
[0xb79f09f0] get() /var/www/somedirectory/securityfile.inc:10
[0xb79ef068] __construct() /var/www/somedirectory/phpfile.php:3

This code was previously running on a server with libapache2-mod-php5 and PHP version 5.2.6 and Apache 2.2.9. We moved everything to a server running newer versions of everything and started getting these segfaults along with reports that users are intermittently getting blank pages when they attempt to access the site. It would appear that the two are related and the segfaults are being caused by the code, but I've no idea how to begin to track down what might be wrong, nor if it's even in fact possible for PHP code to cause this. I don't actually know anything about PHP, and therefore didn't write this code. So my questions are:

  1. Could the code actually be causing segmentation faults in Apache? Am I interpreting this output properly?

  2. How does one debug PHP code? I tried to use Firebug and its companion plugins, but it required more web programming experience than I have.

  3. Could modules loaded into PHP itself cause issues with how the PHP module functions? I understand that with mod_php5 installed that's how Apache processes PHP requests/scripts, but does the actual PHP5 install have any bearing on how that's done? By that I mean that I have the following installed:

    libapache2-mod-php5 5.3.2-1ubuntu4.7
    php5 5.3.2-1ubuntu4.7
    php5-cli 5.3.2-1ubuntu4.7
    php5-common 5.3.2-1ubuntu4.7
    php5-curl 5.3.2-1ubuntu4.7
    php5-mysql 5.3.2-1ubuntu4.7

I'm not sure how they work together, if they do at all, like if I could simply uninstall php5 all together and leave libapache2-mod-php5 if that would make a difference.

Thanks in advance for any advice you can give me on tracking this down. If you need the actual lines from the PHP scripts themselves I can provide them as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泅人 2024-11-11 01:25:15

多年来,我在无数场合看到 PHP 导致 apache 崩溃,主要有两个原因:

  • php 解析器中的许多错误之一和 php 中的错误之一。 解释器(尤其是 &references)
  • PHP 程序中的递归导致

堆栈溢出Bug 似乎会随着时间的推移而修复,但 php 仍然是 php...

Over the years I've seen PHP cause apache crashes on NUMEROUS occasions, from mainly 2 causes :

  • one of the many bugs in the php parser & interpreter (especially with &references)
  • stack overflows caused by recursion in PHP programs

Bugs seem to get fixed with time but php is still php...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文