php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27425 Uncaught exception in try catch block
Submitted: 2004-02-27 13:02 UTC Modified: 2004-03-02 10:12 UTC
Votes:6
Avg. Score:4.8 ± 0.4
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:3 (60.0%)
From: kase at gmx dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-02-27 (dev) OS: linux
Private report: No CVE-ID: None
 [2004-02-27 13:02 UTC] kase at gmx dot net
Description:
------------
If you throw an exception in a function, which is called in a try/catch block, after creating 2 objects of a class, which has a function or method in __destruct(), the exception won?t be caught.

If you create the objects $v1 and $v2 of 2 different classes, and both classes _have_ the function __destruct(), and the second class (of $v2) have a function or method in __destruct(), the problem will exist, too.

Reproduce code:
---------------
<?php
class some_class {
    public function __destruct() {
         time(); // any function/method call will do
                 // language structures will not
    }
}

function test() {
    $v1 = new some_class();
    $v2 = new some_class();
    throw new Exception();
}

try {
    test();
} catch (Exception $e) { 
} 
?>

Expected result:
----------------
The exception should be caught

Actual result:
--------------
Fatal error: Uncaught exception 'exception' in /var/www/legendz/web/test/test.php5:12 Stack trace: #0 /var/www/legendz/web/test/test.php5(16): test() #1 {main} thrown in /var/www/legendz/web/test/test.php5 on line 12


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-02 10:05 UTC] kase at gmx dot net
I tested this bug again, and i think, it is fixed in newest cvs, now.

Maybe related to these bugfixes:

1. http://news.php.net/article.php?group=php.internals&article=8268
2. http://news.php.net/article.php?group=php.internals&article=8280
 [2004-03-02 10:12 UTC] derick@php.net
Cool, let's close it then. Please reopen if it doesn't seem fixed again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 21:01:26 2024 UTC