Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5350 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68820 invoked by uid 1010); 11 Nov 2003 21:38:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 68786 invoked by uid 1007); 11 Nov 2003 21:38:41 -0000 Message-ID: <20031111213841.68785.qmail@pb1.pair.com> To: internals@lists.php.net Date: Tue, 11 Nov 2003 19:38:45 -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 Content-Type: multipart/mixed; boundary="------------010704000101020905000908" X-Posted-By: 200.196.104.198 Subject: [PATCH] Internal Hashtables bug From: cunha17@uol.com.br (Cristiano Duarte) --------------010704000101020905000908 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, if this is a bug, the patch attached fixes it. Best Regards, Cristiano Duarte --------------010704000101020905000908 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) { --------------010704000101020905000908--