Skip to content

Commit a82d55c

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: JIT: Fix OP_DATA read from an unwritten slot in zend_jit_assign_dim_op()
2 parents 6947fe1 + a1975b1 commit a82d55c

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ PHP NEWS
7171
is reloaded from memory). (ndossche)
7272
. Fixed bug GH-24386 (JIT: register operand must be loaded before the typed
7373
reference check). (ndossche)
74+
. Fixed bug GH-24437 (JIT: Fix OP_DATA read from an unwritten slot in
75+
zend_jit_assign_dim_op()). (waroad)
7476

7577
- PDO:
7678
. Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated.

‎ext/opcache/jit/zend_jit_ir.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13670,9 +13670,10 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit,
1367013670
if (!zend_jit_spill_store_inv(jit, op3_addr, real_addr, op1_data_info)) {
1367113671
return 0;
1367213672
}
13673-
op3_addr = real_addr;
13673+
arg2 = jit_ZVAL_ADDR(jit, real_addr);
13674+
} else {
13675+
arg2 = jit_ZVAL_ADDR(jit, op3_addr);
1367413676
}
13675-
arg2 = jit_ZVAL_ADDR(jit, op3_addr);
1367613677
ir_CALL_3(IR_VOID, ir_CONST_FC_FUNC(zend_jit_assign_op_to_typed_ref),
1367713678
reference, arg2, ir_CONST_FC_FUNC(binary_op));
1367813679

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
GH-24437 (JIT: tracing JIT gives wrong sum for `$a[0] += $i + 1` on an array parameter in a loop)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable=1
7+
opcache.enable_cli=1
8+
opcache.jit=tracing
9+
--FILE--
10+
<?php
11+
class C {
12+
public int $prop = 10;
13+
}
14+
15+
function f($a) {
16+
for ($i = 0; $i < 3; $i++) {
17+
@$a[0] += $i + 1;
18+
}
19+
return $a[0];
20+
}
21+
22+
function g(array $a) {
23+
for ($i = 0; $i < 3; $i++) {
24+
$a[0] += $i + 1;
25+
}
26+
return $a[0];
27+
}
28+
29+
function h($a) {
30+
for ($i = 0; $i < 3; $i++) {
31+
$a[2] %= $i + 1;
32+
$x = $a[0] %= 1;
33+
}
34+
}
35+
36+
var_dump(f([1 => 2]));
37+
$x = 10;
38+
var_dump(g([&$x]), $x);
39+
$c = new C;
40+
var_dump(g([&$c->prop]), $c->prop);
41+
@h([]);
42+
?>
43+
DONE
44+
--EXPECT--
45+
int(6)
46+
int(16)
47+
int(16)
48+
int(16)
49+
int(16)
50+
DONE

0 commit comments

Comments
 (0)