Skip to content

Fix GH-24438: Preserve indirect types in JIT side traces - #24699

Open
aasul wants to merge 1 commit into
php:PHP-8.4from
aasul:fix/gh24438-jit-indirect-84
Open

aasul wants to merge 1 commit into
php:PHP-8.4from
aasul:fix/gh24438-jit-indirect-84

Conversation

@aasul

@aasul aasul commented Oct 25, 2026

Copy link
Copy Markdown

Fixes #24438

the tracing jit can enter a side trace at SEND_FUNC_ARG after a FETCH_DIM_FUNC_ARG has already executed in the parent trace.

when regular ssa information isn't available, zend_jit_trace_build_tssa() initializes live-in temporaries with a fallback type mask that doesn't include MAY_BE_INDIRECT. this can leave an indirect operand without the corresponding type information.

zend_jit_send_ref() relies on that bit to emit the conditional indirect dereference. without it, the jit can handle the temporary incorrectly when a dynamic call switches between by-value and by-reference arguments.

the fix adds MAY_BE_INDIRECT to the temporary fallback mask. it also adds a phpt regression test that alternates between by-value and by-reference calls and verifies that the correct array elements are updated.

i tested the change on php 8.5.13-dev using linux x86_64 debug nts builds from the same source revision. the original implementation fails the regression test with an assertion in zval_get_long_func(), while the patched version passes with the expected values.

the full ext/opcache/tests/jit/ suite completed with 515 passes, no failures and 10 skips due to missing extensions or platform requirements.

i also verified that the original reproducer produces the same warnings as the interpreter after the fix. additional checks involving existing references, array aliasing and copy-on-write behavior matched interpreter results.

the original issue reproduces on php 8.4.28-dev as well. the patch was developed and validated on php 8.5; php 8.4 patch validation is not yet included in these results.

release, zts and other architectures haven't been tested locally.

@aasul
aasul requested a review from dstogov as a code owner October 25, 2026 18:52
Copilot AI balanced review requested due to automatic review settings October 25, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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

Great job! Especially for someone who's new.

This is right, most VM opcodes don't leave IS_INDIRECT zvals, but a few do as you found out. Indeed, we may have no preciser type information, and it must be conservative. It's understandable why this is forgotten.

One note though: your commit doesn't seem linked to your account, is there a typo in your git config email address?

@aasul

aasul commented Oct 26, 2026

Copy link
Copy Markdown
Author

@ndossche Yeah there is a typo i accidentally put a first name

@aasul
aasul force-pushed the fix/gh24438-jit-indirect-84 branch from d07e075 to f2e088e Compare October 26, 2026 05:39
@aasul

aasul commented Oct 26, 2026

Copy link
Copy Markdown
Author

@ndossche Forgot to put my complete answer i had just waken up: thanks for the technical review and i fixed the commit author issue

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.

Tracing JIT: segfault on $f($arr[k]) when $f alternates between by-value and by-reference functions

3 participants