Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Oct 21, 2026

Copy link
Copy Markdown
Owner

zend_jit_trace_update_condition_ranges() tested OP1_INFO() twice where the second check should be OP2_INFO(), so comparing an integer with a float or numeric-string literal narrowed the integer's range as if both were integers. With $x < 1.0e19 true for PHP_INT_MAX, $x + 1 lost its overflow check and the trace returned int(-9223372036854775808) instead of float(9.2233720368547758E+18); debug builds instead fail the end_inputs->count == res_inputs->count assertion in zend_jit_math_helper(). The typo dates from e701146.

Comparisons against float or string variables still wrap on this branch, but that is the optimizer bug phpGH-24088 (php#24110), which reproduces with the JIT disabled. The > arm's mixed bound at line 3764 was checked; it only widens the range and has no observable effect, so it is left alone.

Found while testing the phpGH-24088 fix; verified on a PHP-8.4 debug NTS build (hybrid VM) under tracing, function JIT, and with the 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.
@iliaal

iliaal commented Oct 22, 2026

Copy link
Copy Markdown
Owner Author

Promoted to php#24528.

@iliaal iliaal closed this Oct 22, 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