Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5331 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99708 invoked by uid 1010); 10 Nov 2003 03:02:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 99684 invoked by uid 1007); 10 Nov 2003 03:02:09 -0000 Message-ID: <20031110030209.99683.qmail@pb1.pair.com> To: internals@lists.php.net Date: Mon, 10 Nov 2003 01:01:56 -0200 User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4.1) Gecko/20031008 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <20031026165338.18992.qmail@pb1.pair.com> In-Reply-To: <20031026165338.18992.qmail@pb1.pair.com> Content-Type: multipart/mixed; boundary="------------050708030401000300080005" X-Posted-By: 200.196.104.198 Subject: Re: internal hashtables [patch included] From: cunha17@uol.com.br (Cristiano Duarte) --------------050708030401000300080005 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi all, I guess I found a bug at "zend_compile.c". IMHO when you want to create an internal hashtable, that will be filled with internal zvals (malloc'ed instead of emalloc'ed), you should pass the "internal zval destructor" to the hashtable initialization function. Currently, "zend_compile.c" uses the "default zval destructor" for internal and standard zvals. It leads to some error messages (about efree'ing blocks that weren't emalloc'ed) at the end of execution. Am I right, I mean is this the correct behaviour of an internal hashtable ? Anyway, the patch attached fixes it. Best Regards, Cristiano Duarte --------------050708030401000300080005 Content-Type: text/plain; name="ze2_internal_symtables.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ze2_internal_symtables.patch" ? php-src/ZendEngine1 Index: php-src/Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.491 diff -u -r1.491 zend_compile.c --- php-src/Zend/zend_compile.c 7 Nov 2003 10:22:16 -0000 1.491 +++ php-src/Zend/zend_compile.c 10 Nov 2003 02:50:54 -0000 @@ -3511,6 +3511,7 @@ void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC) { zend_bool persistent_hashes = (ce->type == ZEND_INTERNAL_CLASS) ? 1 : 0; + dtor_func_t zval_dtor = ((persistent_hashes) ? ZVAL_INTERNAL_PTR_DTOR : ZVAL_PTR_DTOR); ce->refcount = 1; ce->constants_updated = 0; @@ -3527,8 +3528,9 @@ } else { ALLOC_HASHTABLE(ce->static_members); } - zend_hash_init_ex(ce->static_members, 0, NULL, ZVAL_PTR_DTOR, persistent_hashes, 0); - zend_hash_init_ex(&ce->constants_table, 0, NULL, ZVAL_PTR_DTOR, persistent_hashes, 0); + + zend_hash_init_ex(ce->static_members, 0, NULL, zval_dtor, persistent_hashes, 0); + zend_hash_init_ex(&ce->constants_table, 0, NULL, zval_dtor, persistent_hashes, 0); zend_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, 0); if (nullify_handlers) { --------------050708030401000300080005--