Skip to content

Fix GH-16957: Assertion failure in array_shift with self-referencing array - #16970

Closed
ndossche wants to merge 1 commit into
php:PHP-8.3from
ndossche:fix-16957
Closed

ndossche wants to merge 1 commit into
php:PHP-8.3from
ndossche:fix-16957

Conversation

@ndossche

Copy link
Copy Markdown
Member

We have an RC1 violation because we're immediately dereferencing and copying the resulting array in the test case. Instead, transfer the lifetime using ZVAL_COPY_VALUE and unwrap only after the internal iterator is reset.

Targeting 8.3 because it's an unlikely bug to hit and 8.2 is almost EOL.

…ng array

We have an RC1 violation because we're immediately dereferencing and
copying the resulting array in the test case. Instead, transfer the
lifetime using ZVAL_COPY_VALUE and unwrap only after the internal
iterator is reset.
@ndossche
ndossche requested a review from bukka as a code owner November 27, 2024 19:31
@ndossche ndossche linked an issue Nov 27, 2024 that may be closed by this pull request
@bukka
bukka requested a review from iluuu1994 November 27, 2024 22:14

@bukka bukka 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.

It looks good to me but adding also Ilija as it's kind of more engine related...

@iluuu1994 iluuu1994 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.

Looks correct, thank you!

Comment thread ext/standard/array.c
idx++;
}
RETVAL_COPY_DEREF(val);
ZVAL_COPY_VALUE(return_value, val);

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.

Nit: RETVAL_COPY_VALUE()

Comment thread ext/standard/array.c
idx++;
}
RETVAL_COPY_DEREF(val);
ZVAL_COPY_VALUE(return_value, val);

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.

Same here

@ndossche ndossche closed this in f1fc4e8 Nov 29, 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.

Assertion failure in array_shift with self-referencing array

3 participants