Skip to content

Conversation

@TysonAndre
Copy link
Contributor

(And any PECLs returning &zend_empty_array in the handler->get_properties overrides to save memory)

Closes GH-9697

This is similar to the fix used in d9651a9 for array_walk.

This should make it safer for php-src (and PECLs, long-term) to return the empty immutable array in handler->get_properties to avoid wasting memory. See #9697 (comment)

The only possible internal iterator position for the empty array is at the end of the empty array (nInternalPointer=0).
The zend_hash*del* helpers will always set nInternalPointer to 0 when an array becomes empty,
regardless of previous insertions/deletions/updates to the array.

@TysonAndre TysonAndre requested a review from dstogov October 10, 2022 20:27
@dstogov
Copy link
Member

dstogov commented Oct 11, 2022

This will work of course, but I think it's safer to make a change in ext/ffi and return a mutable array. see #9716

@Girgias
Copy link
Member

Girgias commented Jan 25, 2023

@dstogov it seems that in #9716 you agreed to commit this solution, is this just an oversight and forogot to merge this or are there other reasons?

@dstogov
Copy link
Member

dstogov commented Jan 26, 2023

I'll take a deeper look on Monday (January 30).
Should this be targeted to PHP-8.1?

@Girgias
Copy link
Member

Girgias commented Jan 26, 2023

I'll take a deeper look on Monday (January 30). Should this be targeted to PHP-8.1?

As it seems to be fixing crashes I would say yes.

dstogov
dstogov previously approved these changes Jan 30, 2023
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

Lets commit this.

@TysonAndre TysonAndre changed the base branch from PHP-8.0 to PHP-8.1 January 30, 2023 13:59
@TysonAndre TysonAndre dismissed dstogov’s stale review January 30, 2023 13:59

The base branch was changed.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

All tests are broken because of missing skipif.inc

@TysonAndre TysonAndre requested a review from dstogov January 31, 2023 14:26
(And any PECLs returning `zend_empty_array` in the handler->get_properties
overrides)

Closes phpGH-9697

This is similar to the fix used in d9651a9
for array_walk.

This should make it safer for php-src (and PECLs, long-term) to return
the empty immutable array in `handler->get_properties` to avoid wasting memory.
See php#9697 (comment)

The only possible internal iterator position for the empty array is at the end
of the empty array (nInternalPointer=0).
The `zend_hash*del*` helpers will always set nInternalPointer to 0 when an
array becomes empty,
regardless of previous insertions/deletions/updates to the array.
@TysonAndre TysonAndre merged commit fe2dc2b into php:PHP-8.1 Feb 3, 2023
@TysonAndre TysonAndre deleted the fix-reset-ffi-crash branch February 3, 2023 14:29
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.

3 participants