PHP编程段错误
我一直在使用以下内容对网站进行编程:
- Zend Framework 1.11.5(完整的MVC)
- PHP 5.3.6
- Apache 2.2.19
- CentOS 5.6 i686 virtuozzo on vps
- cPanel WHM 11.30.1(build 4)
- Mysql 5.1.56-log
- Mysqli API 5.1 .56
突然对 mysql 执行了一些“SHOW CREATE TABLE”查询,我得到了 这。
[Wed Jul 20 17:35:23 2011
] [notice] EACCELERATOR(5827): PHP crashed on opline 138 of fetch_fields() at /usr/lib/php/Zend/Db/Statement/Mysqli.php:235
我尝试禁用 eaccelerator 但没有成功
[Wed Jul 20 17:45:34 2011] [warn] [client 190.78.208.30] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Jul 20 17:45:34 2011] [error] [client 190.78.208.30] Premature end of script headers: index.php
[Wed Jul 20 17:45:34 2011] [error] mod_fcgid: process /usr/local/cpanel/cgi-sys/php5(11562) exit(communication error), get unexpected signal 11
[Wed Jul 20 17:45:34 2011] [warn] [client 190.78.208.30] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Jul 20 17:45:34 2011] [error] [client 190.78.208.30] Premature end of script headers: index.php
有问题的行是这样的: $row = $db->fetchRow("SHOW CREATE TABLE 222AFI ");。如果我在执行之前返回,一切都会顺利。 $db 是 Zend_Db_Adapter_Mysqli 的实例。最糟糕的是这不是确定性的。该程序有时可以通过,有时则不能。通常它不会在不使 php 崩溃的情况下通过该行。
<?php
class Admin_DbController extends Controller_BaseController
{
/**
*
*/
public function updateSqlDefinitionsAction()
{
$db = Zend_Registry::get('db');
$row = $db->fetchRow("SHOW CREATE TABLE 222AFI");
}
}
?>
我还没有写信给[电子邮件受保护],因为我没有<一href="https://bugs.php.net/bugs-generate-backtrace.php" rel="nofollow">https://bugs.php.net/bugs-generate-backtrace.php。这可能很愚蠢,但我尝试用“--enable-debug”重新编译 apache(这是一个生产服务器)。然而,“PHP Apache 模块:运行 httpd -X,并访问导致 PHP 崩溃的脚本”是我无法正常工作的部分。服务器告诉我端口 80 已被使用。
谁能给我一些建议吗? 如果我做了一些疯狂的事情,至少还有其他选择吗?
我可以尝试在午夜重新编译 apache,但很高兴知道我不会破坏任何东西。你如何看待这一点对我来说非常重要。
编辑:
我必须使用 --enable-debug 编译 php。这很奇怪,它并没有像通常那样崩溃。这很难,20次尝试也许只有一次失败。如果使用 -X 启动 apache,则 php 更难崩溃,因为 httpd 需要很长时间才能响应。
EDIT2:
即使是在 20 次尝试之后,如果我在没有 -X 标志的情况下启动 httpd,也可能会使其崩溃。不过,我模拟了一个初始化 $_SERVER 变量的脚本,以使 Zend 相信它是通过浏览器调用的。当我使用“php crash.php”执行此脚本多次(例如 50 次)时,一切都会正常。我开始相信这与 php 重用进程有关。我正在使用 mod_fcgi 运行 apache 并且:
Server version: Apache/2.2.19 (Unix)
Server built: Jul 20 2011 19:18:58
Cpanel::Easy::Apache v3.4.2 rev9999
Server's Module Magic Number: 20051115:28
Server loaded: APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
I've been programming a site using:
- Zend Framework 1.11.5 (complete MVC)
- PHP 5.3.6
- Apache 2.2.19
- CentOS 5.6 i686 virtuozzo on vps
- cPanel WHM 11.30.1 (build 4)
- Mysql 5.1.56-log
- Mysqli API 5.1.56
Suddenly doing a few "SHOW CREATE TABLE" query to mysql, i got this.
[Wed Jul 20 17:35:23 2011
] [notice] EACCELERATOR(5827): PHP crashed on opline 138 of fetch_fields() at /usr/lib/php/Zend/Db/Statement/Mysqli.php:235
I've tried disabling eaccelerator without success
[Wed Jul 20 17:45:34 2011] [warn] [client 190.78.208.30] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Jul 20 17:45:34 2011] [error] [client 190.78.208.30] Premature end of script headers: index.php
[Wed Jul 20 17:45:34 2011] [error] mod_fcgid: process /usr/local/cpanel/cgi-sys/php5(11562) exit(communication error), get unexpected signal 11
[Wed Jul 20 17:45:34 2011] [warn] [client 190.78.208.30] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Wed Jul 20 17:45:34 2011] [error] [client 190.78.208.30] Premature end of script headers: index.php
The problematic line is this: $row = $db->fetchRow("SHOW CREATE TABLE 222AFI ");. If i return before it executes, everything goes fine. $db is instance of Zend_Db_Adapter_Mysqli. The worst part is that is not deterministic. The program can pass some times and some others not. Normally it WON'T pass the line without crashing php.
<?php
class Admin_DbController extends Controller_BaseController
{
/**
*
*/
public function updateSqlDefinitionsAction()
{
$db = Zend_Registry::get('db');
$row = $db->fetchRow("SHOW CREATE TABLE 222AFI");
}
}
?>
I haven't written to [email protected] because i haven't the https://bugs.php.net/bugs-generating-backtrace.php. It may be dumb, but i tried recompiling apache with "--enable-debug", (this is a production server). However "PHP Apache Module: Run httpd -X, and access the script that crashes PHP" Is the part i don't get working. The server tells me the port 80 is already being used.
Can anyone give me some advice?
If i'm doing something mad, at least some other options?
I can try to recompile apache at midnight, but it'd be great to know i won't break anything. How you see this is very important to me.
EDIT:
I got to compile php with --enable-debug. This is weird, it is not crashing as it would normally do. It's hard, of 20 attempts maybe one crashes. And if start apache with -X, it's even harder to get php crashing because httpd takes too long to respond.
EDIT2:
Even if it's after 20 attempts, i can make it crash if i start httpd without -X flag. However i emulated a script which initializes $_SERVER variables to make Zend believe it's being called through a browser. When i execute this script with "php crash.php" many times (like 50) everything goes normal. I'm starting to believe it has something to do with php re-used processes. I'm running apache with mod_fcgi and:
Server version: Apache/2.2.19 (Unix)
Server built: Jul 20 2011 19:18:58
Cpanel::Easy::Apache v3.4.2 rev9999
Server's Module Magic Number: 20051115:28
Server loaded: APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
请查看 https://bugs.php.net/bug.php?id= 55414,终于有人搞定了。部分解决方案比我的实施得更好。
please take a look at https://bugs.php.net/bug.php?id=55414, someone finally got with it. The partial solution is better implemented than mine.
您可以在服务器上运行 phpinfo() 并发布 thread_safety 的结果吗?如果你的apache不是线程安全的,那么php应该以同样的方式编译。
can you run a phpinfo() on the server and post the result for thread_safety? if your apache is not thread safe, then php should be compiled the same way.
首先尝试编写一个重现问题的最小示例,即不使用 Zend 框架、Apache 等。只需一个 10 行左右的脚本即可设置数据库连接并发出查询。
First try writing a minimal example that reproduces the problem, i.e. not using Zend framework, Apache etc. Just a 10-line or so script that sets up a database connection and issues a query.
我找到了一个临时解决方案。这很丑陋,但很合适:
您需要将 $this->_config 替换为真正的连接数组。
该脚本运行任何返回行的 SQL 命令。现在是我正在采取的解决方案。如果有人愿意主动帮助我,我仍然有资源。我也是使用 PHPUnit 和 Zend 时出现 PHP 段错误的人(确定性地)。我在工作中做这一切,没有资源来测试它。感谢您的理解。
I found a temporary solution. This is ugly, but fits:
You'll need to replace $this->_config with a real connection array.
This script runs any SQL command which returns rows. For now is the solution i'm taking. If someone wishes to help me proactively i still have the sources. I'm also the guy who has the PHP seg-fault using PHPUnit with Zend (deterministically). I'm doing all this in my job, don't have the resources to test out of it. Thank you for your comprehension.
这里的建议帮助修复了我正在处理的 Web 服务的分段错误:
http://kb.zend.com/index.php?View=entry&EntryID=436
“解决方法是为 php.ini 中的参数‘date.timezone’设置一个值。例如:
date.timezone = "美国/纽约"
支持的时区列表可在此处找到 - www.php.net/manual/en/timezones.php”
A suggestion here helped fixed my segmentation fault for a web service I was dealing with:
http://kb.zend.com/index.php?View=entry&EntryID=436
"The workaround is to set a value to the parameter 'date.timezone' in php.ini. For example:
date.timezone = "America/New_York"
The list of supported timezones is available here - www.php.net/manual/en/timezones.php"