From: ninzya at inbox dot lv Operating system: Windows XP PHP version: 5.3.0beta1 PHP Bug Type: Scripting Engine problem Bug description: Weird behavior under high load
Description: ------------ My configuration is Windows XP, Apache 2.2.11.0, PHP 5.3.0beta1, i'm coding a framework and periodically i am performing stress tests with apache's ab.exe. Once my framework has become quite processive (lotsa operations involved in request processing), there started to appear unexpected PHP errors/warning in a PHP error log file. For details see reproduce code. Reproduce code: --------------- I was performing periodical stress testing by running "ab.exe -c 30 -n 10000 http://..../myframeworkpage.php". Sometimes PHP error log had been empty after 10000 req. stress testing, sometimes there were some errors/warning (from 1 to 10 usually), and these errors were reporting absurd things happening around. What i noticed, is that under heavy load PHP manages to implicitly reset some variables to NULL value, or "lose value", which results in NULL value. Here are some of those errors and my assumptions for those errors: 1) "PHP Notice: Use of undefined constant - assumed '' in ... on line 25", where line #25 is "$Db->connect( DB_PERS, DB_HOST, DB_PORT, DB_USER, DB_PASS);". This is definately failure of PHP. 2) "PHP Fatal error: Call to a member function fetch() on a non-object in ... on line 611" where line #611 is "while( $this->Db->fetch( $this->query));". Please note that this cycle is contained within __destruct() method (probably $Db property is being destroyed too soon when php execution ends, but i assume it was also implicitly reset to NULL). Definately failure of PHP. 3) "PHP Warning: mysql_pconnect(): Access denied for user 'root'@'localhost' (using password: NO) in ... on line 163" where line #163 is "$link =mysql_pconnect( $host .':' .$port, $user, $pass, $clientFlags);" and $pass was never set to null or whatsoever (it contains string password, always). I could assume here failure of MySQL server. 4) "PHP Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in ... on line 483" where line #483 is "return '\'' .mysql_real_escape_string( $data, $this->link) .'\'';" and i'm 100% sure $link property is not null at the step, when call to mysql_real_escape_string is issued. I could assume here failure of MySQL server, which resulted in resource to become null (which is also absurd). 5) "PHP Warning: Invalid argument supplied for foreach() in ... on line 414" where line #414 is "foreach( $patchset as $blockId =>$fill)", and $patchset is a reference to an array, always. Definately failure of PHP. And much more such examples, which all say the same thing - "i got the null value, what the hell?". I tried to make some stress testings for such code as: class X { public function __construct() { } public function __destruct() { } public function test() { } public function Y() { return new Y( $this); } } class Y { protected $X; public function __construct( $X) { $this->X =$X; } public function __destruct() { $this->X->test(); } } $X =new X(); $Y =$X->Y(); $C =$X->Y(); $A =$X->Y(); but it executed successfully with no errors. I tried 300000 requests, everything went fine. But, when i stress-test my framework, PHP *sometimes* acts weird. So far i failed to find compact reproduction code for this issue. Expected result: ---------------- I expect to see no warnings described in "Reproduce code" section. Actual result: -------------- PHP under heavy load implicitly resets random variable's value to NULL or "looses" random variable's value, which results in assignment of NULL value to that variable. -- Edit bug report at http://bugs.php.net/?id=47712&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47712&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47712&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47712&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47712&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47712&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47712&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47712&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47712&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47712&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47712&r=support Expected behavior: http://bugs.php.net/fix.php?id=47712&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47712&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47712&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47712&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47712&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47712&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47712&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47712&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47712&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47712&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47712&r=mysqlcfg