Re: cvs: ZendEngine2(PHP_5_3) / zend.h zend_API.c zend_execute_API.c zend_vm_def.h zend_vm_execute.h php-src/main main.c php.h

Marcus Boerger <[email protected]>
Newsgroups gmane.comp.php.cvs.zend
Message-ID <[email protected]>
Hello Anthony, Dmitry,

  both of you found the issue and I cannot reproduce it. However I guess we
basically have to save/restore the handler as well. The attached patch
works for me (as good as I could reproduce the issues).

marcus

Monday, August 11, 2008, 11:09:47 AM, you wrote:

> Hi Marcus,

> It looks like we got memory leaks after this patch.

> Bug #28721 (appendChild() and insertBefore() unset DOMText) 
> [ext/dom/tests/bug28721.phpt]
> Phar: create with illegal path [ext/phar/tests/create_path_error.phpt]


> [Mon Aug 11 12:19:03 2008]  Script: 
> '/home/dmitry/php/php5.3/ext/phar/tests/create_path_error.php'
> /home/dmitry/php/php5.3/Zend/zend_variables.h(45) :  Freeing 0x08E80360 
> (14 bytes), 
> script=/home/dmitry/php/php5.3/ext/phar/tests/create_path_error.php
> /home/dmitry/php/php5.3/Zend/zend_variables.c(120) : Actual location 
> (location was relayed)
> [Mon Aug 11 12:19:03 2008]  Script: 
> '/home/dmitry/php/php5.3/ext/phar/tests/create_path_error.php'
> /home/dmitry/php/php5.3/Zend/zend_builtin_functions.c(1525) :  Freeing 
> 0x08E8231C (20 bytes), 
> script=/home/dmitry/php/php5.3/ext/phar/tests/create_path_error.php

> Could you please look into them.

> Thanks. Dmitry.


> Marcus Boerger wrote:
>> helly         Fri Aug  8 17:47:52 2008 UTC
>> 
>>   Modified files:              (Branch: PHP_5_3)
>>     /php-src/main     main.c php.h 
>>     /ZendEngine2      zend.h zend_API.c zend_execute_API.c zend_vm_def.h 
>>                       zend_vm_execute.h 
>>   Log:
>>   - MFH error handling, now with save, replace, restore
>>   
>> 




Best regards,
 Marcus

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
php-error-handling-stack-5.3-20080811.diff.txt (text/plain, 3.4 KB)
Index: Zend/zend.h
===================================================================
RCS file: /repository/ZendEngine2/zend.h,v
retrieving revision 1.293.2.11.2.9.2.25
diff -u -p -d -r1.293.2.11.2.9.2.25 zend.h
--- Zend/zend.h	8 Aug 2008 17:47:26 -0000	1.293.2.11.2.9.2.25
+++ Zend/zend.h	11 Aug 2008 16:14:39 -0000
@@ -752,11 +752,12 @@ typedef enum {
 typedef struct {
 	zend_error_handling_t  handling;
 	zend_class_entry       *exception;
+	zval                   *user_handler;
 } zend_error_handling;
 
 ZEND_API void zend_save_error_handling(zend_error_handling *current TSRMLS_DC);
 ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC);
-ZEND_API void zend_restore_error_handling(const zend_error_handling *saved TSRMLS_DC);
+ZEND_API void zend_restore_error_handling(zend_error_handling *saved TSRMLS_DC);
 
 #endif /* ZEND_H */
 
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals.h,v
retrieving revision 1.141.2.3.2.7.2.17
diff -u -p -d -r1.141.2.3.2.7.2.17 zend_globals.h
--- Zend/zend_globals.h	24 Jul 2008 22:21:38 -0000	1.141.2.3.2.7.2.17
+++ Zend/zend_globals.h	11 Aug 2008 16:14:39 -0000
@@ -222,7 +222,6 @@ struct _zend_executor_globals {
 
 	int user_error_handler_error_reporting;
 	zval *user_error_handler;
-	zval *user_error_handler_old;
 	zval *user_exception_handler;
 	zend_stack user_error_handlers_error_reporting;
 	zend_ptr_stack user_error_handlers;
Index: Zend/zend_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_API.c,v
retrieving revision 1.296.2.27.2.34.2.48
diff -u -p -d -r1.296.2.27.2.34.2.48 zend_API.c
--- Zend/zend_API.c	8 Aug 2008 17:47:28 -0000	1.296.2.27.2.34.2.48
+++ Zend/zend_API.c	11 Aug 2008 16:14:39 -0000
@@ -3467,6 +3467,10 @@ ZEND_API void zend_save_error_handling(z
 {
 	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);
+	}
 }
 /* }}} */
 
@@ -3474,23 +3478,29 @@ ZEND_API void zend_replace_error_handlin
 {
 	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;
-
-	if (error_handling == EH_NORMAL) {
-		EG(user_error_handler)     = EG(user_error_handler_old);
-	} else {
-		EG(user_error_handler_old) = EG(user_error_handler);
-		EG(user_error_handler)     = NULL;
-	}
 }
 /* }}} */
 
-ZEND_API void zend_restore_error_handling(const zend_error_handling *saved TSRMLS_DC) /* {{{ */
+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;
+	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;
 }
 /* }}} */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.