Skip to content

Fix GH-25449: Keep by-ref containers out of converted FUNC_ARG fetches - #464

Closed
iliaal wants to merge 1 commit into
PHP-8.6from
fix/gh-25449-func-arg-ref-call
Closed

iliaal wants to merge 1 commit into
PHP-8.6from
fix/gh-25449-func-arg-ref-call

Conversation

@iliaal

@iliaal iliaal commented Nov 14, 2026

Copy link
Copy Markdown
Owner

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

…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
@iliaal

iliaal commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#25458.

@iliaal iliaal closed this Nov 14, 2026
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.

1 participant