From: raulsanchezt at gmail dot com Operating system: Fedora 6 PHP version: 5.2.10 PHP Bug Type: *Programming Data Structures Bug description: while() is not working on PHP5 as it always did
Description: ------------ What you'll see below are three versions of the same code. Version a) worked for me all along PHP4 (for years and years). After upgrading to PHP5 it's not working anymore. Version b) does not work either. Version c) does work. Version a) runs indefinitely until I Ctrl-C it. Version b) runs indefinitely until I Ctrl-C it. Version c) runs for a millionth of a second and shows the expected result This code is a great simplification of what I actually coded (a MySQL wrapper). I spent two full weeks trying to find out what was wrong with my new PHP5/MySQL/Zend Debugger/Eclipse implementation until I bumped into this little, unbelievable, never-to-be-expected bug. Reproduce code: --------------- // version a) while() does not work anymore $v_x = 0; $v_success = false; $_SESSION["v_attempts"] = 20; while(!$v_success or ($v_x < $_SESSION["v_attempts"])) { // irrelevant code that may change the value of $v_success $v_x++; } // version b) while() does not work either $v_x = 0; $v_success = false; $_SESSION["v_attempts"] = 20; while((!$v_success) or ($v_x < $_SESSION["v_attempts"])) { // irrelevant code that may change the value of $v_success $v_x++; } // version c) this one works $v_x = 0; $v_success = false; $_SESSION["v_attempts"] = 20; while(($v_success = false) or ($v_x < $_SESSION["v_attempts"])) { // irrelevant code that may change the value of $v_success $v_x++; } Expected result: ---------------- I expect to see the actual value of $v_x, which should be 20. Actual result: -------------- (gdb) run testfile.php Starting program: /usr/local/zend/bin/php testfile.php warning: Lowest section in system-supplied DSO at 0xffffe000 is .hash at ffffe0b4 (no debugging symbols found) (no debugging symbols found) [Thread debugging using libthread_db enabled] [New Thread 4160407232 (LWP 24052)] Error while reading shared library symbols: Cannot find new threads: generic error (no debugging symbols found) (no debugging symbols found) (no debugging symbols found) Segmentation fault NOTE: all three versions produce this output. The three versions run the same as CGIs and as Firefox scripts. -- Edit bug report at http://bugs.php.net/?id=48923&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48923&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48923&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48923&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48923&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48923&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48923&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48923&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48923&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48923&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48923&r=support Expected behavior: http://bugs.php.net/fix.php?id=48923&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48923&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48923&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48923&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48923&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48923&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48923&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48923&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48923&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48923&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48923&r=mysqlcfg