From: christian dot cal at gmx dot de Operating system: Windows XP PHP version: 5.1.2 PHP Bug Type: Session related Bug description: foreach($_SESSION as $key => $value) unset($_SESSION[$key]) crashes apache2
Description: ------------ I am using PHP as an apache2 modul. When trying to unset all vars that are stored in $_SESSION i use a foreach loop combined with unset. This method crashes the apache2. I moved from PHP 4.4.2 to 5.1.2. The unmodified code works for 4.4.2 but crashes the server when using 5.1.2. Reproduce code: --------------- foreach ($_SESSION as $key => $value){ unset($_SESSION[$key]); } Expected result: ---------------- All vars should be removed from $_SESSION So i tried this: $helper=&$_SESSION; foreach ($helper as $key => $value){ unset($helper[$key]); } This code does what I have expected from the code above. Also this works: $helper=array_keys($_SESSION); foreach ($helper as $key){ unset($_SESSION[$key]); } -- Edit bug report at http://bugs.php.net/?id=36646&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36646&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36646&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36646&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36646&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36646&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36646&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36646&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36646&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36646&r=support Expected behavior: http://bugs.php.net/fix.php?id=36646&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36646&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36646&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36646&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36646&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36646&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36646&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36646&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36646&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36646&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36646&r=mysqlcfg