[intl] fix leak when iterating IntlBreakIterator parts iterators - #279
Open
iliaal wants to merge 1 commit into
Open
[intl] fix leak when iterating IntlBreakIterator parts iterators#279iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
Iterating a parts iterator left the IntlPartsIterator object holding a counted self-reference through the embedded zend_object_iterator's wrapping_obj, so refcount destruction could never complete and every getPartsIterator() loop leaked the iterator object, its wrapper and the retained current element. zoi_with_current_dtor() now also invalidates the current element, and the parts iterator no longer addrefs itself (wrapping_obj stays UNDEF as in the plain BreakIterator iterator), making teardown deterministic. Sibling audit: string_enum_object_iterator_funcs still requires wrapping_obj for owner error handling in move_forward/rewind and keeps its self-reference; ResourceBundle uses an independent iterator implementation and is unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Iterating the result of IntlBreakIterator::getPartsIterator() leaked memory on every loop because the IntlPartsIterator object held a counted self-reference through its embedded zend_object_iterator's wrapping_obj, so refcount destruction could never complete; the retained current element was additionally never released at iterator destruction. This makes zoi_with_current_dtor() invalidate the current element and leaves the parts iterator's wrapping_obj UNDEF (as the plain BreakIterator iterator already does), so teardown is now deterministic: repeated 300k-iteration loops went from leaking about 85 MB to a flat zero-delta profile, verified by a new phpt that fails on unpatched builds. Sibling audit: the StringEnumeration iterator path still requires wrapping_obj for owner error handling in move_forward/rewind and keeps its self-reference, and ResourceBundle uses an independent iterator implementation.