ID:               33598
 Updated by:       [EMAIL PROTECTED]
 Reported By:      carlo dot razzeto at mtginfo dot com
-Status:           Open
+Status:           Verified
 Bug Type:         Class/Object related
 Operating System: *
 PHP Version:      5CVS-2005-07-07


Previous Comments:
------------------------------------------------------------------------

[2005-07-07 15:27:12] carlo dot razzeto at mtginfo dot com

The same error is occuring when attempting to throw an exception from
the deconstructor of a class while the script is shutting down. As my
linux box is currnetly not available I tested on my windows
workstation. I will verify this later today with my linux box.

Z:\PHP\php5-win32-latest>php -version
PHP 5.1.0-dev (cli) (built: Jul  7 2005 12:24:46)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2004 Zend Technologies

Z:\PHP\php5-win32-latest>php test.php
Construct
Hello World
Destruct

Fatal error: Exception thrown without a stack frame in Unknown on line
0

------------------------------------------------------------------------

[2005-07-07 09:43:16] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



------------------------------------------------------------------------

[2005-07-07 01:46:59] carlo dot razzeto at mtginfo dot com

Description:
------------
When performing an operation which throws an exception in the
__destruct method of a class, the following Error is generated

Fatal error: Exception thrown without a stack frame in Unknown on line
0

I have only observed this happening when an object goes out of scope
because the script has ended. Rather than generating a scripting engine
error, PHP should allow for the script to deal with the error, for
instance when an exception handler has been specified by the script.

Reproduce code:
---------------
    class test {
        function __construct() {
            echo "Construct\n";
        }
        
        function greet() {
            echo "Hello World\n";
        }
        
        function __destruct() {
            echo "Destruct\n";
            throw new Exception( 'test' );
        }
    }
    
    $test = new test();
    $test->greet();

Expected result:
----------------
Construct
Hello World
Destruct

Fatal error: Uncaught exception 'Exception' with message 'test' in
/home/crazzeto/test.php:13
Stack trace:
#0 /home/crazzeto/test.php(13): test::__destruct()
#1 /home/crazzeto/test.php(20): test::__destruct()
#2 /home/crazzeto/test.php(20): unknown()
#3 {main}
  thrown in /home/crazzeto/test.php on line 13


Actual result:
--------------
[EMAIL PROTECTED] crazzeto]$ php test.php
Construct
Hello World
Destruct

Fatal error: Exception thrown without a stack frame in Unknown on line
0



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=33598&edit=1

Reply via email to