Skip to content

Commit 674f998

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: ext/opcache: Fix tracing JIT range narrowing against a non-integer operand
2 parents 17b4c5f + 07fc708 commit 674f998

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

‎NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ PHP NEWS
4949
MariaDB PAM account). (lazerg)
5050

5151
- Opcache:
52+
. Fixed tracing JIT returning a wrapped integer instead of a float on
53+
integer overflow after an integer was compared with a float or
54+
numeric-string literal. (Ilia Alshanetsky)
5255
. Fixed bug GH-17626 (JIT corrupts an opline handler when blacklisting a
5356
root trace at the opcache.jit_max_root_traces limit, causing spurious
5457
"Too few arguments" errors and crashes). (RV7PR)

‎ext/opcache/jit/zend_jit_trace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3721,7 +3721,7 @@ static void zend_jit_trace_update_condition_ranges(const zend_op *opline, const
37213721
zend_long op1_min, op1_max, op2_min, op2_max;
37223722

37233723
if ((OP1_INFO() & MAY_BE_ANY) != MAY_BE_LONG
3724-
|| (OP1_INFO() & MAY_BE_ANY) != MAY_BE_LONG) {
3724+
|| (OP2_INFO() & MAY_BE_ANY) != MAY_BE_LONG) {
37253725
return;
37263726
}
37273727

‎ext/opcache/tests/jit/cmp_010.phpt‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--TEST--
2+
JIT CMP: 010 Integer range must not be narrowed by a comparison with a non-integer operand
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit=tracing
8+
opcache.jit_hot_func=1
9+
opcache.jit_hot_loop=1
10+
opcache.jit_hot_return=1
11+
opcache.jit_hot_side_exit=1
12+
--EXTENSIONS--
13+
opcache
14+
--SKIPIF--
15+
<?php
16+
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
17+
?>
18+
--FILE--
19+
<?php
20+
function lt_float(int $x) {
21+
if ($x < 1.0e19) {
22+
return $x + 1;
23+
}
24+
return 0;
25+
}
26+
function lt_string(int $x) {
27+
if ($x < "1e19") {
28+
return $x + 1;
29+
}
30+
return 0;
31+
}
32+
function le_float(int $x) {
33+
if ($x <= -1.0e19) {
34+
return 0;
35+
}
36+
return $x - 1;
37+
}
38+
foreach ([1, 2, 3, PHP_INT_MAX] as $v) {
39+
$r = lt_float($v);
40+
}
41+
echo "int < float: ";
42+
var_dump($r);
43+
foreach ([1, 2, 3, PHP_INT_MAX] as $v) {
44+
$r = lt_string($v);
45+
}
46+
echo "int < numeric string: ";
47+
var_dump($r);
48+
foreach ([1, 2, 3, PHP_INT_MIN] as $v) {
49+
$r = le_float($v);
50+
}
51+
echo "int <= float (false): ";
52+
var_dump($r);
53+
?>
54+
--EXPECT--
55+
int < float: float(9.223372036854776E+18)
56+
int < numeric string: float(9.223372036854776E+18)
57+
int <= float (false): float(-9.223372036854776E+18)

0 commit comments

Comments
 (0)