From:             
Operating system: Linux/Windows
PHP version:      5.3.2
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Throwing an exception in a destructor causes invalid catching

Description:
------------
When exceptions are thrown in destructor, PHP5.3.x does not catch any
exceptions 

in caller's "try" block.

In addition, destructor's "try" block catches exceptions of caller.



Probably this behavior is bug because it works correctly on PHP5.2.13.

Test script:
---------------
<?php

class aaa {

        public function __destruct() {

                try {

                        throw new Exception(__CLASS__);

                } catch(Exception $ex) {

                }

        }

}

function bbb() {

        $a = new aaa();

        throw new Exception(__FUNCTION__);

}

try {

        bbb();

        echo "must be skipped !!!";

} catch(Exception $ex) {

        echo $ex;

}

Expected result:
----------------
exception 'Exception' with message 'aaa' in example.php:5

Stack trace:

#0 example.php(16): aaa->__destruct()

#1 example.php(16): bbb()

#2 {main}

exception 'Exception' with message 'bbb' in example.php:13

Stack trace:

#0 example.php(16): bbb()

#1 {main}

Actual result:
--------------
exception 'Exception' with message 'bbb' in example.php:13

Stack trace:

#0 example.php(16): bbb()

#1 {main}



Next exception 'Exception' with message 'aaa' in example.php:5

Stack trace:

#0 example.php(16): aaa->__destruct()

#1 example.php(16): bbb()

#2 {main}

must be skipped !!!

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52361&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52361&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52361&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52361&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52361&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52361&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52361&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52361&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52361&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52361&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52361&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52361&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52361&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52361&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52361&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52361&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52361&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52361&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52361&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52361&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52361&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52361&r=mysqlcfg

Reply via email to