Iterators and new destructors

php.internals

Rob Richards

22 years ago
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

Andi Gutmans

22 years ago
I submitted the patch for checking free_storage != NULL. Marcus, will have to look into SPL and see if dtor is more suitable than free_storage. Andi At 11:39 AM 2/8/2004 -0500, Rob Richards wrote:

Marcus Börger

22 years ago
Hello Andi, without looking at the code i guessed iterators needed both, destruction and cleaning. But unfortunatley i fear i cannot look into it until wednesday. So i took a few mins right now and i'd say you should commit Rob's patch which seems correct. regards marcus Sunday, February 8, 2004, 6:08:47 PM, you wrote:
> I submitted the patch for checking free_storage != NULL. > Marcus, will have to look into SPL and see if dtor is more suitable than > free_storage.
> Andi
> At 11:39 AM 2/8/2004 -0500, Rob Richards wrote: >>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 >> >>-- >>PHP Internals - PHP Runtime Development Mailing List >>To unsubscribe, visit: http://www.php.net/unsub.php
-- Best regards, Marcus mailto:helly@php.net