Fix GH-22490: NULL deref for a pipe on the lhs of ??=#22494
Open
iliaal wants to merge 1 commit into
Open
Conversation
devnexen
approved these changes
Jun 28, 2026
devnexen
left a comment
Member
There was a problem hiding this comment.
lgtm, you might need a more refined commit title though
bc6aa84 to
73b86f9
Compare
Contributor
Author
|
Renamed for clarity. |
Member
More like : |
zend_compile_var_inner did not route ZEND_AST_PIPE through zend_compile_memoized_expr, so a pipe on the left-hand side of ??= was recompiled during the FETCH pass. zend_compile_pipe synthesizes a fresh call node on each pass, so the memoized-result lookup keyed by that node returned NULL and was dereferenced. Memoize the pipe like the other call kinds zend_is_call() already recognizes. Fixes phpGH-22490
73b86f9 to
e7aa318
Compare
Contributor
Author
|
Done, retitled the PR and commit to |
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.
A pipe expression on the left-hand side of
??=, e.g.(1 |> f(...))->g ??= 2, crashes the compiler with a NULL pointer dereference inzend_compile_memoized_expr. The coalesce-assign LHS is compiled twice and call results are memoized by AST-node pointer, butzend_compile_pipedesugars the pipe into a freshly allocated call node on each pass, so the fetch pass looks up a pointer the compile pass never stored. Memoizing the whole pipe under its stable original node, consistent withzend_is_call(), makes the pipe compile once and the fetch pass reuse the result.Fixes #22490