Skip to content

Commit 6eed02b

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix phpGH-18899: JIT function crash when emitting undefined variable warning and opline is not set yet
2 parents 9b7252b + 56c4ddf commit 6eed02b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5944,6 +5944,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
59445944
ir_IF_FALSE_cold(if_def);
59455945

59465946
// zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
5947+
jit_SET_EX_OPLINE(jit, opline);
59475948
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var));
59485949

59495950
ref2 = jit_EG(uninitialized_zval);
@@ -5960,6 +5961,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
59605961
ir_IF_FALSE_cold(if_def);
59615962

59625963
// zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var)));
5964+
jit_SET_EX_OPLINE(jit, opline);
59635965
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op2.var));
59645966

59655967
ref2 = jit_EG(uninitialized_zval);

ext/opcache/tests/jit/gh18899.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-18899 (JIT function crash when emitting undefined variable warning and opline is not set yet)
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable=1
7+
opcache.enable_cli=1
8+
opcache.jit=1205
9+
opcache.jit_buffer_size=8M
10+
--FILE--
11+
<?php
12+
function ptr2str()
13+
{
14+
for ($i=0; $i<8; $i++) {
15+
$ptr >>= 8;
16+
}
17+
}
18+
str_repeat("A",232).ptr2str();
19+
?>
20+
--EXPECTF--
21+
Warning: Undefined variable $ptr in %s on line %d

0 commit comments

Comments
 (0)