Skip to content

Fix GH-11972: RecursiveCallbackFilterIterator regression in 8.1.18 - #12086

Closed
ndossche wants to merge 1 commit into
php:PHP-8.1from
ndossche:fix-spl-11972
Closed

ndossche wants to merge 1 commit into
php:PHP-8.1from
ndossche:fix-spl-11972

Conversation

@ndossche

@ndossche ndossche commented Aug 30, 2023 •

Copy link
Copy Markdown
Member

When you do an assignment between two zvals (no, not zval*), you copy all fields. This includes the additional u2 data. So that means for example the Z_NEXT index gets copied, which in some cases can therefore cause a cycle in zend_hash lookups.
Instead of doing an assignment, we should be doing a ZVAL_COPY (or ZVAL_COPY_VALUE for non-refcounting cases). This avoids copying u2.

EDIT: as a side note, I wonder if there's more mistakes like this in spl (or other code) 🤔

When you do an assignment between two zvals (no, not zval*), you copy
all fields. This includes the additional u2 data. So that means for
example the Z_NEXT index gets copied, which in some cases can therefore
cause a cycle in zend_hash lookups.
Instead of doing an assignment, we should be doing a ZVAL_COPY (or
ZVAL_COPY_VALUE for non-refcounting cases). This avoids copying u2.
@ndossche
ndossche requested a review from Girgias August 30, 2023 19:27
@ndossche ndossche linked an issue Aug 30, 2023 that may be closed by this pull request

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ndossche ndossche closed this in ffd7018 Aug 30, 2023
ndossche added a commit that referenced this pull request Aug 30, 2023
When you do an assignment between two zvals (no, not zval*), you copy
all fields. This includes the additional u2 data. So that means for
example the Z_NEXT index gets copied, which in some cases can therefore
cause a cycle in zend_hash lookups.
Instead of doing an assignment, we should be doing a ZVAL_COPY (or
ZVAL_COPY_VALUE for non-refcounting cases). This avoids copying u2.

Closes GH-12086.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RecursiveCallbackFilterIterator regression in 8.1.18

2 participants