PHP编程seg故障
我一直在使用以下工具对网站进行编程:PHP编程seg故障,php,apache,segmentation-fault,mysqli,mod-fcgid,Php,Apache,Segmentation Fault,Mysqli,Mod Fcgid,我一直在使用以下工具对网站进行编程: Zend Framework 1.11.5(完整的MVC) PHP 5.3.6 Apache 2.2.19 CentOS 5.6 i686 vps上的大师 cPanel WHM 11.30.1(构建4) Mysql 5.1.56-log Mysqli API 5.1.56 突然对mysql做了一些“showcreatetable”查询,我得到了这个 [Wed Jul 20 17:35:23 2011 ] [notice] EACCELERATOR(5827)
[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
我试过禁用每个加速器,但没有成功
[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(“showcreatetable222afi”);。如果我在它执行之前返回,一切都会好起来$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");
}
}
?>
能否在服务器上运行phpinfo()并发布结果以确保线程安全?如果您的apache不是线程安全的,那么php应该以同样的方式编译。首先尝试编写一个再现问题的最小示例,即不使用Zend framework、apache等。只需一个10行左右的脚本,即可建立数据库连接并发出查询。我找到了一个临时解决方案。这很难看,但适合:
public function selectCmd($q){
$charsFrom = array("\\a", "\\t", "\\n", "\\v", "\\f", "\\r", "\\\\", "\\0", "\\\"", "\\\'", "\\b");
$charsTo = array("\a", "\t", "\n", "\v", "\f", "\r", "\\", "\0", "\"", "\'", "\b");
exec('echo ' . escapeshellarg($q) . ' | mysql' .
' -h ' . escapeshellarg($this->_config['host']).
' -u ' . escapeshellarg($this->_config['username']).
' -p' . escapeshellarg($this->_config['password']).
' ' . escapeshellarg($this->_config['dbname']), $output);
$colNames = explode("\t", array_shift($output));
foreach ($colNames as &$colName){
$colName = str_replace($charsFrom, $charsTo, $colName);
}
unset($colName);
$rowSet = array();
foreach ($output as $line){
$row = array();
$rawRow = explode("\t", $line);
for ($i = 0; $i < count($rawRow); ++ $i){
$row[$colNames[$i]] = str_replace($charsFrom, $charsTo, $rawRow[$i]);
}
$rowSet[] = $row;
}
return $rowSet;
}
公共函数selectCmd($q){
$charsFrom=array(“\\a”、“\\t”、“\\n”、“\\v”、“\\f”、“\\r”、“\\\”、“\\0”、“\\\”、“\\\”、“\\b”);
$charsTo=array(“\a”、“\t”、“\n”、“\v”、“\f”、“\r”、“\\”、“\0”、“\”、“\”、“\”、“\b”);
exec('echo'.escapeshellarg($q)。'mysql'。
“-h”.escapeshellarg($this->_config['host'])。
“-u”.escapeshellarg($this->_config['username'])。
“-p”.escapeshellarg($this->_config['password'])。
''.escapeshellarg($this->_config['dbname']),$output);
$colNames=explode(“\t”,数组移位($output));
foreach($colNames as&$colName){
$colName=str_replace($charsFrom,$charsTo,$colName);
}
unset($colName);
$rowSet=array();
foreach($行输出){
$row=array();
$rawRow=explode(“\t”,$line);
对于($i=0;$i
您需要将$this->\u配置替换为真正的连接数组
此脚本运行任何返回行的SQL命令。目前我正在采取的解决方案是。如果有人想主动帮助我,我仍然有消息来源。我也是那个使用PHPUnit和Zend(决定性地)的PHP seg错误的人。我在工作中做这一切,没有足够的资源去测试。谢谢你的理解。请看一看,终于有人理解了。部分解决方案的实现比我的更好。这里的一个建议帮助修复了我处理的web服务的分段错误: “解决方法是在php.ini中为参数'date.timezone'设置一个值。例如: date.timezone=“美国/纽约”
支持的时区列表可在此处找到-www.php.net/manual/en/timezones.php“”服务器告诉我端口80已被使用。“请先杀死现有的
httpd
进程。”。这意味着停止Apache服务,如果您将其配置为作为服务运行。在这种情况下,FCGI包装器可能必须转储回溯。我假设有一种方法可以将文件从缓存/optcoded中排除。为什么不这样做,直到你找到一个更持久的解决方案?属于:问答系统管理员你建议我发表这个问题吗?嗨,谢谢。PHP也是在禁用线程安全的情况下编译的,问题是要从Zend MVC中找出错误非常困难。这是我第二次因为在PHP中执行操作而出现PHP seg错误。另一个是MVC内部的PHPUnit。可悲的是,我不得不在没有解决真正问题的情况下寻找解决办法。每个故障原因都有一个解决方案?我不这么认为:(
public function selectCmd($q){
$charsFrom = array("\\a", "\\t", "\\n", "\\v", "\\f", "\\r", "\\\\", "\\0", "\\\"", "\\\'", "\\b");
$charsTo = array("\a", "\t", "\n", "\v", "\f", "\r", "\\", "\0", "\"", "\'", "\b");
exec('echo ' . escapeshellarg($q) . ' | mysql' .
' -h ' . escapeshellarg($this->_config['host']).
' -u ' . escapeshellarg($this->_config['username']).
' -p' . escapeshellarg($this->_config['password']).
' ' . escapeshellarg($this->_config['dbname']), $output);
$colNames = explode("\t", array_shift($output));
foreach ($colNames as &$colName){
$colName = str_replace($charsFrom, $charsTo, $colName);
}
unset($colName);
$rowSet = array();
foreach ($output as $line){
$row = array();
$rawRow = explode("\t", $line);
for ($i = 0; $i < count($rawRow); ++ $i){
$row[$colNames[$i]] = str_replace($charsFrom, $charsTo, $rawRow[$i]);
}
$rowSet[] = $row;
}
return $rowSet;
}