Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix GH-18899: JIT function crash when emitting undefined variable warning and opline is not set yet
This commit is contained in:
Niels Dossche 2025-06-23 20:10:27 +02:00
commit 6eed02bacc
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5
2 changed files with 23 additions and 0 deletions

View file

@ -5944,6 +5944,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
ir_IF_FALSE_cold(if_def); ir_IF_FALSE_cold(if_def);
// zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var))); // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
jit_SET_EX_OPLINE(jit, opline);
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var)); ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var));
ref2 = jit_EG(uninitialized_zval); ref2 = jit_EG(uninitialized_zval);
@ -5960,6 +5961,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
ir_IF_FALSE_cold(if_def); ir_IF_FALSE_cold(if_def);
// zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var))); // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var)));
jit_SET_EX_OPLINE(jit, opline);
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op2.var)); ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op2.var));
ref2 = jit_EG(uninitialized_zval); ref2 = jit_EG(uninitialized_zval);

View file

@ -0,0 +1,21 @@
--TEST--
GH-18899 (JIT function crash when emitting undefined variable warning and opline is not set yet)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=1205
opcache.jit_buffer_size=8M
--FILE--
<?php
function ptr2str()
{
for ($i=0; $i<8; $i++) {
$ptr >>= 8;
}
}
str_repeat("A",232).ptr2str();
?>
--EXPECTF--
Warning: Undefined variable $ptr in %s on line %d