Skip to content

JIT: Fix zend_jit_trace_find_init_fcall_op() - #23449

Open
arnaud-lb wants to merge 1 commit into
php:masterfrom
arnaud-lb:find-init-fcall
Open

JIT: Fix zend_jit_trace_find_init_fcall_op()#23449
arnaud-lb wants to merge 1 commit into
php:masterfrom
arnaud-lb:find-init-fcall

Conversation

@arnaud-lb

@arnaud-lb arnaud-lb commented Aug 25, 2026

Copy link
Copy Markdown
Member

zend_jit_trace_find_init_fcall_op() tries to find the INIT_FCALL opline corresponding to a ZEND_JIT_TRACE_INIT_CALL record, but it fails to do so in the ZEND_JIT_TRACE_FAKE_INIT_CALL case, for nested calls.

The ZEND_JIT_TRACE_FAKE_INIT_CALL case implies that p points to a sequence of ZEND_JIT_TRACE_INIT_CALL trace records. The first loop in zend_jit_trace_find_init_fcall_op() is supposed to find the first opline after the sequence, but it mistakenly decrements p after initially incrementing it. As a result p eventually points to an invalid record.

It works for non-nested calls because the p->op == ZEND_JIT_TRACE_VM condition is true on the first iteration in that case.

This can not lead to a crash or miscompilations, but this results in lost optimization opportunities.

zend_jit_trace_find_init_fcall_op() tries to find the INIT_FCALL opline
corresponding to a ZEND_JIT_TRACE_INIT_CALL record, but it fails to do so in the
ZEND_JIT_TRACE_FAKE_INIT_CALL case, for nested calls.

The first loop is supposed to find the first opline after the sequence of
ZEND_JIT_TRACE_INIT_CALL record, but it mistakenly decrements 'p' after
initially incrementing it. As a result 'p' eventually points to an invalid
record.

It works for non-nested calls because the 'p->op == ZEND_JIT_TRACE_VM' condition
is true on the first iteration in that case.

This can not lead to a crash or miscompilations, but this results in lost
optimization opportunities.
@arnaud-lb
arnaud-lb marked this pull request as ready for review August 25, 2026 14:01
@arnaud-lb
arnaud-lb requested a review from dstogov as a code owner August 25, 2026 14:01
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.

1 participant