Skip to content

ext/opcache: Fix tracing JIT range narrowing against a non-integer operand - #24528

Closed
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/jit-cmp-range-op2
Closed

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/jit-cmp-range-op2

Conversation

@iliaal

@iliaal iliaal commented Oct 22, 2026

Copy link
Copy Markdown
Member

zend_jit_trace_update_condition_ranges() checked the first operand twice, allowing comparisons with float or numeric-string literals to narrow an integer's range and remove overflow checks. It now requires both operands to be integers, preserving float results on overflow. Found while testing #24110; verified with PHP-8.4 debug NTS under tracing JIT, function JIT, and with JIT disabled.

…erand

zend_jit_trace_update_condition_ranges() tested OP1_INFO() twice instead of
OP1_INFO() and OP2_INFO(), so comparing an integer with a float or
numeric-string literal narrowed the integer's range as if both operands were
integers. zend_may_overflow() then ruled out overflow of a following $x + 1,
the overflow check was omitted, and the trace returned a wrapped integer
instead of a float, or failed an assertion while compiling. Require both
operands to be integers, as the rest of the function assumes.

@jorgsowa jorgsowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fix looks good to me, fixes simple typo. However there is still bug for non-literal cases. May be tackled in follow-up

@iliaal

iliaal commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Yeah, this is just the minimal fix.

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

wowie

@iliaal iliaal closed this in 07fc708 Oct 22, 2026
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.

4 participants