Skip to content

Conversation

nielsdos
Copy link
Member

zend_array_dup_ht_iterators() loops over the hash table iterators and can call zend_hash_iterator_add(). zend_hash_iterator_add() can resize the array causing a crash in zend_array_dup_ht_iterators().

We solve this by refetching the iter pointer after an add happened.

… list while adding

zend_array_dup_ht_iterators() loops over the hash table iterators and
can call zend_hash_iterator_add(). zend_hash_iterator_add() can resize
the array causing a crash in zend_array_dup_ht_iterators().

We solve this by refetching the iter pointer after an add happened.
Zend/zend_hash.c Outdated

while (iter != end) {
if (iter->ht == source) {
size_t iter_index = iter - EG(ht_iterators);
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternative idea is to use indices in the while loop, but then we have to fetch EG(ht_iterators) always in the loop body which seemed more expensive.

Copy link
Member

Choose a reason for hiding this comment

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

I think indices are going to be better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I have pushed a commit to do that.

@nielsdos nielsdos marked this pull request as ready for review September 25, 2024 17:28
@nielsdos nielsdos closed this in fdd6ba6 Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Segmentation fault when resizing hash table iterator list while adding

2 participants