PHP/Apache 在脚本上崩溃(分段错误(11)

2024-04-13php开发问题
17

本文介绍了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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17