#24708 [Opn]: Calling restore_error_handler() in a destructor crashes things

From: Date: Fri, 18 Jul 2003 19:54:06 +0000
Subject: #24708 [Opn]: Calling restore_error_handler() in a destructor crashes things
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-44267@lists.php.net to get a copy of this message
 ID:               24708
 User updated by:  auroraeosrose at hotmail dot com
 Reported By:      auroraeosrose at hotmail dot com
 Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Windows XP Pro SP1
 PHP Version:      5CVS-2003-07-18 (dev)
 New Comment:

Oh, btw, using $error = &new Error(); makes no difference, the
script(and php, and apache) crash exactly the same way.  Other
functions, echoes, etc. that I've tried work fine in the destructor.


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

[2003-07-18 14:26:49] auroraeosrose at hotmail dot com

Description:
------------
Latest php snap of 5.0
Apache 2 filter
mb_string, gd, mssql, and mysql only dll's loaded

Error handler class - constructor calls set_error_handler and works
just fine, descructor calls restore_error_handler and the server
crashes nicely - not only the phpdll but all of apache as well in a
second message.  I have some dump files if you need them, just leave a
message.

Reproduce code:
---------------
<?php
class Error
{
	function __construct()
	{
		set_error_handler(array(&$this, 'handler'));
	}

	function __destruct()
	{
		restore_error_handler();
	}

	function handler($no, $str, $file, $line, $ctx)
	{
		echo '<pre>';
		echo 'no   : ' . $no . "\n";
		echo 'str  : ' . $str . "\n";
		echo 'file : ' . $file . "\n";
		echo 'line : ' . $line . "\n";
		echo 'ctx  : ';
		print_r($ctx);
		echo '</pre>';
	}

}

$error = new error();
echo $dog;

?> 

Expected result:
----------------
no   : 8
str  : Undefined variable:  dog
file : ****/test.php
line : 29
ctx  : Array
(
    [GLOBALS] => Array
 *RECURSION*
    [_POST] => Array
        (
        )

    [_GET] => Array
        (
        )

    [_COOKIE] => Array
        (
        )

    [_FILES] => Array
        (
        )

    [error] => error Object
        (
        )

)

Actual result:
--------------
Comment out the restore_error_handler and it works jim dandy


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


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



Thread (4 messages)

« previous php.bugs (#44267) next »