Bug #70938 [NEW]: Handled Exception throws in finally block

From: Date: Wed, 18 Nov 2015 17:11:46 +0000
Subject: Bug #70938 [NEW]: Handled Exception throws in finally block
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197320@lists.php.net to get a copy of this message
From: xela at xela dot org dot ua Operating system: All PHP version: 5.6.15 Package: Scripting Engine problem Bug Type: Bug Bug description:Handled Exception throws in finally block Description: ------------ I think, we can have two problems (bugs?) here: 1) Handled Exception throws in finally block; 2) finally is executed even with throw in catch block. Test script: --------------- <?php class DbTable { public function __construct() { try { throw new \Exception('Database made a boo boo'); } catch (\Exception $e) { // ok, reconnect } } } try { throw new \Exception('Server made a boo boo'); } catch(\Exception $e) { // do smth echo $e->getMessage()."\n"; throw $e; } finally { $db = new DbTable(); echo "Done\n"; } Expected result: ---------------- Server made a boo boo PHP Fatal error: Uncaught exception 'Exception' with message 'Server made a boo boo' in /var/www/html2/sstnet-xl/public/exception-test.php:15 Stack trace: #0 {main} thrown in /var/www/html2/sstnet-xl/public/exception-test.php on line 15 Fatal error: Uncaught exception 'Exception' with message 'Server made a boo boo' in /var/www/html2/sstnet-xl/public/exception-test.php on line 15 Call Stack: 0.0001 231296 1. {main}() /var/www/html2/sstnet-xl/public/exception-test.php:0 0.0001 237392 2. DbTable->__construct() /var/www/html2/sstnet-xl/public/exception-test.php:23 Actual result: -------------- Server made a boo boo Done PHP Fatal error: Uncaught exception 'Exception' with message 'Server made a boo boo' in /var/www/html2/sstnet-xl/public/exception-test.php:15 Stack trace: #0 {main} thrown in /var/www/html2/sstnet-xl/public/exception-test.php on line 15 Fatal error: Uncaught exception 'Exception' with message 'Server made a boo boo' in /var/www/html2/sstnet-xl/public/exception-test.php on line 15 Exception: Database made a boo boo in /var/www/html2/sstnet-xl/public/exception-test.php on line 6 Call Stack: 0.0001 231296 1. {main}() /var/www/html2/sstnet-xl/public/exception-test.php:0 0.0001 237392 2. DbTable->__construct() /var/www/html2/sstnet-xl/public/exception-test.php:23 -- Edit bug report at https://bugs.php.net/bug.php?id=70938&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70938&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70938&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70938&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70938&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70938&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70938&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70938&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70938&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70938&r=support Expected behavior: https://bugs.php.net/fix.php?id=70938&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70938&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70938&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70938&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70938&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70938&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70938&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70938&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70938&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70938&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70938&r=mysqlcfg

« previous php.bugs (#197320) next »