Skip to content

Commit 4a12a9f

Browse files
committed
Fix GH-18294: assertion failure zend_jit_ir.c
The JIT helper `zend_jit_assign_op_to_typed_ref` expects a `zval*` as an argument, so we have to store to the stack if OP1_DATA(=op3) is in a register. Closes GH-18299.
1 parent 9468185 commit 4a12a9f

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ PHP NEWS
2626
. Fixed custom external entity loader returning an invalid resource leading
2727
to a confusing TypeError message. (Girgias)
2828

29+
- Opcache:
30+
. Fixed bug GH-18294 (assertion failure zend_jit_ir.c). (nielsdos)
31+
2932
- OpenSSL:
3033
. Fix memory leak in openssl_sign() when passing invalid algorithm.
3134
(nielsdos)

ext/opcache/jit/zend_jit_ir.c

+7
Original file line numberDiff line numberDiff line change
@@ -13482,6 +13482,13 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit,
1348213482
ref_path = ir_END();
1348313483
ir_IF_TRUE_cold(if_typed);
1348413484

13485+
if (Z_MODE(op3_addr) == IS_REG) {
13486+
zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (opline+1)->op1.var);
13487+
if (!zend_jit_spill_store_inv(jit, op3_addr, real_addr, op1_data_info)) {
13488+
return 0;
13489+
}
13490+
op3_addr = real_addr;
13491+
}
1348513492
arg2 = jit_ZVAL_ADDR(jit, op3_addr);
1348613493
ir_CALL_3(IR_VOID, ir_CONST_FC_FUNC(zend_jit_assign_op_to_typed_ref),
1348713494
reference, arg2, ir_CONST_FC_FUNC(binary_op));

ext/opcache/tests/jit/gh18294.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
GH-18294 (assertion failure zend_jit_ir.c)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.jit=1152
7+
opcache.jit_hot_func=1
8+
opcache.jit_hot_side_exit=1
9+
--FILE--
10+
<?php
11+
$a = [2147483647,2147483647,2147483647,3,0,0,32,2147483584,127];
12+
print_r(@bitwise_small_split($a));
13+
function bitwise_small_split($val) {
14+
$split = 8;
15+
$len = count($val);
16+
while ($i != $len) {
17+
if (!$overflow) {
18+
$overflow = $split <= $remaining ? 0 : $split - $remaining;
19+
} elseif (++$i != $len) {
20+
$fusion[$i] >>= $overflow;
21+
}
22+
}
23+
return $fusion;
24+
}
25+
?>
26+
--EXPECT--
27+
Array
28+
(
29+
[1] => 0
30+
[2] => 0
31+
[3] => 0
32+
[4] => 0
33+
[5] => 0
34+
[6] => 0
35+
[7] => 0
36+
[8] => 0
37+
)

0 commit comments

Comments
 (0)