From:             [EMAIL PROTECTED]
Operating system: linux
PHP version:      5.1.2
PHP Bug Type:     Scripting Engine problem
Bug description:  Object destructors called even after fatal errors

Description:
------------
I just ran into this in CodeGen_PECL, wondering why the script
terminated half-way without giving any message, a stripped down
reproducing example is added below.

Basicly the problem was that a fatal error occuerd (which can't
be caught by an error handler) but my output buffer redirection
code still kicked in, so swallowing the error message from the
still active output buffer

its rather strange that i could implement an error handler
for E_FATAL errors using destructors whereas error_handler()
and register_shutdown_function() can't be used for this

Reproduce code:
---------------
<?php

class ob
{
  private $filename;

  function __construct($filename) {
        $this->filename = $filename;
        ob_start();
  }

  function __destruct() 
  {
        file_put_contents($this->filename, ob_get_clean());
  }
}


$ob = new ob("ob.txt");

foo::bar();

?>

Expected result:
----------------
the error message

 "Fatal error: Class 'foo' not found in /home/hartmut/new/ob.php on line
22"

shown on the console after calling the script

Actual result:
--------------
the error message

 "Fatal error: Class 'foo' not found in /home/hartmut/new/ob.php on line
22"

goes to the "ob.txt" file, not the console, when calling this using CLI,
the destructor is obviously executed *after* error handling

-- 
Edit bug report at http://bugs.php.net/?id=36268&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36268&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36268&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36268&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36268&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36268&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36268&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36268&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36268&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36268&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36268&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36268&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36268&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36268&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36268&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36268&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36268&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36268&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36268&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36268&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36268&r=mysqlcfg

Reply via email to