#41468 [NEW]: Exception is not catched in try-catch block in some environment

From: Date: Wed, 23 May 2007 08:42:05 +0000
Subject: #41468 [NEW]: Exception is not catched in try-catch block in some environment
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112949@lists.php.net to get a copy of this message
From: aleboo at gmail dot com Operating system: Linux PHP version: 5.2.2 PHP Bug Type: Scripting Engine problem Bug description: Exception is not catched in try-catch block in some environment Description: ------------ Problem appears in try-catch block in some environment. When some code throws exception and there is no more any code right after throwing code in try-catchh block, then exception is not catched and it falls to system. Other, upper level try-catch blocks can't catch it too. Not sure about PHP version - it works on Windows with 5.2.0, it was working on Linux with 5.1.x version, but now it not working. Introducing die(), or break in the end of internal part of try-catch blocks sloves the problem, and exception is handled correcty, but it is offcourse workaround. Reproduce code: --------------- class Test{ public function doTest(){ try{ throw new Exception( "test exception" ); // with break or die() here code will work! }catch( Exception $ex ){ return "exception catched"; } return "ok"; } } $testObj = new Test(); $content = $testObj->doTest(); echo( $content ); Expected result: ---------------- "exception catched" text Actual result: -------------- Fatal error: Uncaught exception 'Exception' with message 'test exception' in /path-to-test-file-dir/test.php:5 Stack trace: #0 /path-to-test-file-dir/test.php(14): Test->doTest() #1 {main} thrown in /path-to-test-file-dir/test.php on line 5 -- Edit bug report at http://bugs.php.net/?id=41468&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41468&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41468&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41468&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41468&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41468&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41468&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41468&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41468&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41468&r=support Expected behavior: http://bugs.php.net/fix.php?id=41468&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41468&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41468&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41468&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41468&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41468&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41468&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41468&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41468&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41468&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41468&r=mysqlcfg

« previous php.bugs (#112949) next »