Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7644 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84329 invoked by uid 1010); 8 Feb 2004 16:37:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 84302 invoked from network); 8 Feb 2004 16:37:54 -0000 Received: from unknown (HELO phoebe.host4u.net) (209.150.128.26) by pb1.pair.com with SMTP; 8 Feb 2004 16:37:54 -0000 Received: from ctdprimary (dsta-aa203.pivot.net [66.186.171.203]) by phoebe.host4u.net (8.11.6/8.11.6) with SMTP id i18Gbrn07103 for ; Sun, 8 Feb 2004 10:37:54 -0600 Message-ID: <027501c3ee62$2e21d240$f7dea8c0@cyberware.local> To: Date: Sun, 8 Feb 2004 11:39:53 -0500 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0272_01C3EE38.44EEDD30" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Subject: Iterators and new destructors From: rrichards@ctindustries.net ("Rob Richards") ------=_NextPart_000_0272_01C3EE38.44EEDD30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit It appears that the zend iterators need to go back to using the dtor callback rather than free storage. throwing an unhandled exception in any of the iterator foreach loops in SPL, SXE and DOM results in a segfault due to improper cleanup. To reproduce, put a throw new exception within one of the foreach calls in limititerator or array_iterator from the SPL tests. Registering dtor instead of a free storage callback in zend_iterator_wrap seems to let the iterator objects cleanup properly. Also in zend_objects_store_del_ref, free_storage is never tested so if an object doesn't implement this, it causes a segfault. Patch attached. Rob ------=_NextPart_000_0272_01C3EE38.44EEDD30 Content-Type: text/plain; name="zend_destruct.diff.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zend_destruct.diff.txt" Index: zend_iterators.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /repository/ZendEngine2/zend_iterators.c,v retrieving revision 1.9 diff -u -r1.9 zend_iterators.c --- zend_iterators.c 4 Feb 2004 21:04:12 -0000 1.9 +++ zend_iterators.c 8 Feb 2004 15:54:21 -0000 @@ -54,7 +54,7 @@ zend_iterator_class_entry.name =3D "__iterator_wrapper"; } =20 -static void iter_wrapper_free_storage(zend_object *object TSRMLS_DC) +static void iter_wrapper_dtor(void *object, zend_object_handle handle = TSRMLS_DC) { zend_object_iterator *iter =3D (zend_object_iterator*)object; iter->funcs->dtor(iter TSRMLS_CC); @@ -66,7 +66,7 @@ =09 MAKE_STD_ZVAL(wrapped); Z_TYPE_P(wrapped) =3D IS_OBJECT; - wrapped->value.obj.handle =3D zend_objects_store_put(iter, NULL, = iter_wrapper_free_storage, NULL TSRMLS_CC); + wrapped->value.obj.handle =3D zend_objects_store_put(iter, = iter_wrapper_dtor, NULL, NULL TSRMLS_CC); wrapped->value.obj.handlers =3D &iterator_object_handlers; =20 return wrapped; Index: zend_objects_API.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /repository/ZendEngine2/zend_objects_API.c,v retrieving revision 1.28 diff -u -r1.28 zend_objects_API.c --- zend_objects_API.c 4 Feb 2004 12:30:48 -0000 1.28 +++ zend_objects_API.c 8 Feb 2004 15:54:22 -0000 @@ -136,7 +136,9 @@ obj->dtor(obj->object, handle TSRMLS_CC); } if (obj->refcount =3D=3D 0) { - obj->free_storage(obj->object TSRMLS_CC); + if (obj->free_storage) { + obj->free_storage(obj->object TSRMLS_CC); + } ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); } } ------=_NextPart_000_0272_01C3EE38.44EEDD30--