|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-09-29 12:37 UTC] php at benjaminschulz dot com
Description:
------------
restore_error_handler doesn't work anymore in PHP 5.3.0alpha3-dev (cli) (built: Sep 29 2008 12:17:38)
Reproduce code:
---------------
function foo() { var_dump(__FUNCTION__); }
set_error_handler("foo");
restore_error_handler();
trigger_error("foobar", E_USER_ERROR);'
Expected result:
----------------
A standard error message.
Actual result:
--------------
string(3) "foo"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 17:00:01 2025 UTC |
Same bug encountered with php5.3-200810301330, also with a php crash. Reproduce code: --------------- <?php var_dump ( set_error_handler ('myErrorHandler') ); restore_error_handler (); var_dump ( set_error_handler ('myErrorHandler') ); function myErrorHandler($errno, $errstr, $errfile, $errline) { return true; } Expected result: ---------------- NULL NULL Actual result: -------------- NULL string(14) "myErrorHandler" zend_mm_heap corruptedI made a patch to fix this bug and tested it *successfully* on php5.3-200811170930 (latest snap as I'm writing). I am not an expert in diff/patch, so syntax may be wrong. --- Zend/zend_API.c 2008-11-17 11:02:39.000000000 +0100 +++ Zend/zend_API.c 2008-08-08 19:47:28.000000000 +0200 @@ -3467,10 +3467,6 @@ { current->handling = EG(error_handling); current->exception = EG(exception_class); - current->user_handler = EG(user_error_handler); - if (current->user_handler) { - Z_ADDREF_P(current->user_handler); - } } /* }}} */ @@ -3478,10 +3474,6 @@ { if (current) { zend_save_error_handling(current TSRMLS_CC); - if (error_handling != EH_NORMAL && EG(user_error_handler)) { - zval_ptr_dtor(&EG(user_error_handler)); - EG(user_error_handler) = NULL; - } } EG(error_handling) = error_handling; EG(exception_class) = error_handling == EH_THROW ? exception_class : NULL; @@ -3499,15 +3491,6 @@ { EG(error_handling) = saved->handling; EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL; - if (saved->user_handler && saved->user_handler != EG(user_error_handler)) { - if (EG(user_error_handler)) { - zval_ptr_dtor(&EG(user_error_handler)); - } - EG(user_error_handler) = saved->user_handler; - } else if (saved->user_handler) { - zval_ptr_dtor(&saved->user_handler); - } - saved->user_handler = NULL; } /* }}} */It seems my diff patch failed to apply on some configurations. Here is full functions altered in Zend/zend_API.C (end of file, three functions modified): ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC) /* {{{ */ { current->handling = EG(error_handling); current->exception = EG(exception_class); } /* }}} */ ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC) /* {{{ */ { if (current) { zend_save_error_handling(current TSRMLS_CC); } EG(error_handling) = error_handling; EG(exception_class) = error_handling == EH_THROW ? exception_class : NULL; } /* }}} */ ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC) /* {{{ */ { EG(error_handling) = saved->handling; EG(exception_class) = saved->handling == EH_THROW ? saved->exception : NULL; } /* }}} */