From: matthew at zend dot com Operating system: Linux PHP version: 5.2.2 PHP Bug Type: Session related Bug description: session_start warnings caught by error handler produce fatals
Description: ------------ In http://bugs.php.net/41253, Ralph Schindler notes an issue with how session startup errors due to unwritable session.save_path settings perform. This issue was closed as 'bogus', but I feel that the reviewer did not fully understand the situation. He commented, "You're trying to throw an exception when the engine is shutting down, so you get a pretty much expected fatal error." The engine is not shutting down at this point, however. As Ralph notes in the original bug, under normal circumstances, if session.save_path is not writable, PHP simply emits an E_WARNING, not an E_FATAL, and continues execution. In the example he provides, we get radically different behaviour when using an error handler to trap the E_WARNING and throw it as an exception -- basically, even if a try/catch block is used, the otherwise recoverable error now becomes a fatal one. Please re-examine the issue. Reproduce code: --------------- <? ini_set('session.save_path', '/var/log'); set_error_handler('save_handler', E_ALL); try { session_start(); } catch (Exception $e) { echo $e->getMessage(); } function save_handler($errno, $errmsg) { throw new Exception('Error caught and thrown as exception: ' . $errmsg); } Expected result: ---------------- Error caught and thrown as exception: session_start(): open(/var/log/sess_3e97dad0fe4ce6f285e97593471f2c88, O_RDWR) failed: Permission denied (13) Actual result: -------------- Error caught and thrown as exception: session_start(): open(/var/log/sess_3e97dad0fe4ce6f285e97593471f2c88, O_RDWR) failed: Permission denied (13) Fatal error: Exception thrown without a stack frame in Unknown on line 0 -- Edit bug report at http://bugs.php.net/?id=41270&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41270&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41270&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41270&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41270&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41270&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41270&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41270&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41270&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41270&r=support Expected behavior: http://bugs.php.net/fix.php?id=41270&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41270&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41270&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41270&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41270&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41270&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41270&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41270&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41270&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41270&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41270&r=mysqlcfg