PHP programming seg fault

I programmed the site using:

  • Zend Framework 1.11.5 (full 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 making a few β€œSHOW CREATE TABLE” queries 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 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 problem line is this: $ row = $ db-> fetchRow ("SHOW CREATE TABLE 222AFI") ;. If I return before it is completed, everything will be fine. $ db is an instance of Zend_Db_Adapter_Mysqli. Worst of all, what is not deterministic. A program may run several times, and some may not. Usually it does NOT skip a line without php crashes.

 <?php class Admin_DbController extends Controller_BaseController { /** * */ public function updateSqlDefinitionsAction() { $db = Zend_Registry::get('db'); $row = $db->fetchRow("SHOW CREATE TABLE 222AFI"); } } ?> 

I did not write to internals@lists.php.net because I do not have https://bugs.php.net/bugs-generating-backtrace.php . This might be silly, but I tried recompiling apache with "--enable-debug" (this is a production server). However, β€œPHP Apache Module: Run httpd -X and enter the script that PHP crashes.” Is the part I'm not working. The server tells me that port 80 is already in use.

Can anyone give me some advice? If I am doing something crazy, at least some other options?

I can try recompiling apache at midnight, but it would be great to know that I won't break anything. As you can see, this is very important to me.

EDIT

I need to compile php with --enable-debug. This is strange, this is not a failure, as is usually the case. This is difficult, out of 20 attempts, perhaps one failure. And if you run apache with -X, it is even harder to get php to fail because httpd has been reacting for too long.

EDIT2

Even if it after 20 attempts, I can make it crash if I started httpd without the -X flag. However, I emulated a script that initializes the $ _SERVER variables to make Zend assume that it is being called through the browser. When I execute this script with "php crash.php" many times (e.g. 50), everything goes fine. I am starting to believe that this has something to do with php reusable processes. I run 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 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" 
+6
source share
5 answers

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.

+2
source

Can you run phpinfo () on the server and post the result to thread_safety? if your apache is not thread safe then php should be compiled in the same way.

0
source

First try writing a minimal example that reproduces the problem, i.e. does not use the Zend, Apache, etc. framework Just a 10-line or so script that establishes a connection to the database and issues a request.

0
source

I found a workaround. This is ugly but suitable:

 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; } 

You will need to replace $ this β†’ _ config with a real array of connections.

This script executes any SQL command that returns rows. At the moment, this is the decision I am making. If anyone wants to help me, I still have sources. I am also the one who has PHP seg-fault using PHPUnit with Zend (deterministically). I do all this in my work, I have no resources for testing. Thank you for your understanding.

0
source

This suggestion helped fix my segmentation error for the web service I was dealing with:

http://kb.zend.com/index.php?View=entry&EntryID=436

"Workaround is to set the value for the date.timezone parameter in php.ini. For example:

date.timezone = "America / New_York" A list of supported time zones is available here - www.php.net/manual/en/timezones.php "

0
source

Source: https://habr.com/ru/post/893216/


All Articles