Repository navigation
Conversation
…ches Since phpGH-20628, FETCH_DIM_R and FETCH_OBJ_R expect a VAR container to be unwrapped already. Pass 4 turned FETCH_DIM_FUNC_ARG and FETCH_OBJ_FUNC_ARG into their _R forms once the argument was known to be by-value, without checking where the VAR came from, so a reference returned by a by-reference call or produced by an assignment by reference reached the _R handler. Retype a defining DO_*CALL result and the fetch operand to TMP, so the callee unwraps its return value as it does when the callee is known at compile time. Keep the FUNC_ARG fetch for any other producer that is not an already converted read fetch. Fixes phpGH-25449
Owner
Author
|
Submitted upstream as php#25458. |
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.
With OPcache, f(g()['k']) passes null (debug builds assert in FETCH_DIM_R) when g() returns by reference and f() is not known at compile time. Since phpGH-20628, FETCH_DIM_R and FETCH_OBJ_R assume a VAR container is already unwrapped, but pass 4 converts FETCH_DIM_FUNC_ARG and FETCH_OBJ_FUNC_ARG to the _R form while the container is still the VAR result of the by-ref call, so the callee never unwraps the reference. An assignment by reference as the container, such as f(($y = &$x)['k']), hits the same assertion.
Retype a defining DO_*CALL result to TMP, matching what the compiler emits when the callee is known, and keep the FUNC_ARG fetch for any other producer except an already converted read fetch, so f($a->b['c']) is still optimized.
Reproduced on PHP-8.6 4452ae4 (debug NTS). The test fails before and passes after, and passes under plain, opcache, tracing JIT and function JIT; Zend/tests and ext/opcache/tests show no regressions with and without opcache.
Fixes php#25449