PHP/Apache 在脚本上崩溃(分段错误(11) [英] PHP/Apache crashing on script (Segmentation fault (11)

查看:54
本文介绍了PHP/Apache 在脚本上崩溃(分段错误(11)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[已解决]

我正在 localhost 上运行一个 PHP 脚本(包含一些包含),该脚本在结束前一直崩溃.

I'm running a PHP script (with some includes) on localhost that keeps crashing before the end.

错误报告已开启.Opera、Safari 和 Firefox 返回一个空屏幕.但是 Chrome 会返回:

Error reporting is on. Opera, Safari and Firefox return an empty screen. But Chrome returns:

无法加载网页,因为服务器未发送任何数据.错误代码:ERR_EMPTY_RESPONSE

Unable to load the webpage because the server sent no data. Error code: ERR_EMPTY_RESPONSE

Apache 日志返回:

Apache logs returns:

[Sun Dec 15 19:29:23 2013] [notice] child pid 34267 exit signal分段错误(11)

[Sun Dec 15 19:29:23 2013] [notice] child pid 34267 exit signal Segmentation fault (11)

我第一次遇到问题时使用的是 PHP 5.5.6降级到 PHP 5.4.21 后问题依然存在.

Was using PHP 5.5.6 when I encountered the problem for the first time After downgrading to PHP 5.4.21 the problem still exists.

问题不在脚本内部.随机注释掉几行 50 行代码可以解决问题.让我想知道我的脚本是否可能需要执行很久.

The problem is not inside the script. Randomly commenting out a couple of 50 lines of code solves the problem. Making me wonder if my script might be to long for execution.

有人对我如何解决这个问题有任何建议吗?

Does anyone has any suggestions on how I can resolve this problem?

更新:

问题不仅出现在本地主机上,而且出现在我在 CentOs 6.4 和 PHP 5.3.3 上运行的网络服务器上,在 Apache 上也出现了同样的错误.

Problem doesn't only appears on the localhost but also on my webserver running on CentOs 6.4 and PHP 5.3.3 giving the same error on Apache.

[Sun Dec 15 23:15:10 2013] [notice] child pid 18409 exit signal分段错误(11)

[Sun Dec 15 23:15:10 2013] [notice] child pid 18409 exit signal Segmentation fault (11)

更新 2:

从命令行运行 php 给出:

Running php from the command line gives:

$ php index.php 致命错误:调用未定义函数第 135 行 Encrypt.class.php 中的 mcrypt_create_iv()

$ php index.php Fatal error: Call to undefined function mcrypt_create_iv() in Encrypt.class.php on line 135

在 Encrypt.class.php 的第 135 行之前放置注释后

After placing a comment before line 135 on Encrypt.class.php

$ php index.php
分段错误:11

$ php index.php
Segmentation fault: 11

UPDATE3:(解决方案)

使用 strace (strace php index.php) 在命令行上运行索引后,我在其中一个查询中发现了问题.

After running the index on command line with strace (strace php index.php) I found the problem at one of the queries.

经过更多调试(使用 PDO 而不是我自己的类)后,我发现问题在于设置我自己的 PDO 选项ATTR_PERSISTENT => true".禁用此选项解决了我的问题.

After some more debugging (using PDO instead of my own class) I found out that the problem was setting my own PDO option "ATTR_PERSISTENT => true". Disabling this option solved my problem.

推荐答案

UPDATE3:(解决方案)

UPDATE3: (Solution)

PDO 的持久化选项很可悲地破坏了我的表现.

Persisten option of PDO broke my performance sadly enough.

使用 strace 找到解决方案:使用 strace (strace php index.php) 在命令行上运行索引后,我在其中一个查询中发现了问题.

Found the solution with strace: After running the index on command line with strace (strace php index.php) I found the problem at one of the queries.

分离查询后,我用默认的 PDO 替换了我的类.添加我的班级的选项,直到它再次被打破:经过更多调试(使用 PDO 而不是我自己的类)后,我发现问题在于设置我自己的 PDO 选项ATTR_PERSISTENT => true".禁用此选项解决了我的问题.

After separating the query i replaced my class with default PDO. Adding options of my class till it was broken again: After some more debugging (using PDO instead of my own class) I found out that the problem was setting my own PDO option "ATTR_PERSISTENT => true". Disabling this option solved my problem.

这篇关于PHP/Apache 在脚本上崩溃(分段错误(11)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆