php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41406 try/catch and Exceptions causing an infinite loop
Submitted: 2007-05-16 07:23 UTC Modified: 2007-05-21 08:55 UTC
From: andrew at alliancesoftware dot com dot au Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.2 OS: Fedora Core release 4 (Stentz)
Private report: No CVE-ID: None
 [2007-05-16 07:23 UTC] andrew at alliancesoftware dot com dot au
Description:
------------
If i throw an exception in a try/catch block, and then try throwing the same type of exception after the try/catch block has ended it will infinitely loop through the catch block.

Reproduce code:
---------------
try {
    throw new Exception('first');
} catch (Exception $e) {
    print $e->getMessage()."\n";
}

throw new Exception('second');


Expected result:
----------------
Should just print 'first' and then exit with an uncaught Exception.

Actual result:
--------------
It prints 'first' as expected, but then goes on to infinitely loop through the catch block again printing 'second' from the latter exception (that is outside the catch block)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-16 12:39 UTC] tony2001@php.net
Cannot reproduce:
first

Fatal error: Uncaught exception 'Exception' with message 'second' in /tmp/3.php:8
Stack trace:
#0 {main}
  thrown in /tmp/3.php on line 8

 [2007-05-21 02:15 UTC] andrew at alliancesoftware dot com dot au
On further investigation, bug only happens if the zend optimizer is also loaded:

zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.0.1

(not sure if the bug should be reported here or not, but leaving a comment for anyone else who experiences it)
 [2007-05-21 08:55 UTC] tony2001@php.net
Please update Zend Optimizer to the latest available version and if you're still able to reproduce it, report it to support@zend.com.
Not PHP problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 18:01:31 2024 UTC