1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-15972: Assertion failure in ext/opcache/jit/zend_jit_vm_helpers.c with function JIT (#16001)

This commit is contained in:
Dmitry Stogov
2024-09-24 10:24:08 +03:00
committed by GitHub
parent 07377de110
commit 8f00430a2b
4 changed files with 42 additions and 1 deletions

View File

@@ -231,6 +231,7 @@ ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_jit_loop_counter_helper(ZEND_OPCODE_H
void ZEND_FASTCALL zend_jit_copy_extra_args_helper(EXECUTE_DATA_D);
bool ZEND_FASTCALL zend_jit_deprecated_helper(OPLINE_D);
void ZEND_FASTCALL zend_jit_undefined_long_key(EXECUTE_DATA_D);
void ZEND_FASTCALL zend_jit_undefined_long_key_ex(zend_long key EXECUTE_DATA_DC);
void ZEND_FASTCALL zend_jit_undefined_string_key(EXECUTE_DATA_D);
zend_constant* ZEND_FASTCALL zend_jit_get_constant(const zval *key, uint32_t flags);

View File

@@ -3024,6 +3024,7 @@ static void zend_jit_setup_disasm(void)
REGISTER_HELPER(zend_jit_verify_return_slow);
REGISTER_HELPER(zend_jit_deprecated_helper);
REGISTER_HELPER(zend_jit_undefined_long_key);
REGISTER_HELPER(zend_jit_undefined_long_key_ex);
REGISTER_HELPER(zend_jit_undefined_string_key);
REGISTER_HELPER(zend_jit_copy_extra_args_helper);
REGISTER_HELPER(zend_jit_vm_stack_free_args_helper);
@@ -11716,6 +11717,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
if (!op2_loaded) {
// JIT: hval = Z_LVAL_P(dim);
h = jit_Z_LVAL(jit, op2_addr);
op2_loaded = 1;
}
if (packed_loaded) {
ref = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(_zend_hash_index_find), ht_ref, h);
@@ -11765,6 +11767,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
if (!op2_loaded) {
// JIT: hval = Z_LVAL_P(dim);
h = jit_Z_LVAL(jit, op2_addr);
op2_loaded = 1;
}
if (packed_loaded) {
ref = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(_zend_hash_index_find), ht_ref, h);
@@ -11808,7 +11811,19 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
// JIT: zend_error(E_WARNING,"Undefined array key " ZEND_LONG_FMT, hval);
// JIT: retval = &EG(uninitialized_zval);
jit_SET_EX_OPLINE(jit, opline);
ir_CALL(IR_VOID, jit_STUB_FUNC_ADDR(jit, jit_stub_undefined_offset, IR_FASTCALL_FUNC));
if (Z_MODE(op2_addr) == IS_REG) {
if (!op2_loaded) {
// JIT: hval = Z_LVAL_P(dim);
h = jit_Z_LVAL(jit, op2_addr);
}
if (GCC_GLOBAL_REGS) {
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_long_key_ex), h);
} else {
ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_long_key_ex), h, jit_FP(jit));
}
} else {
ir_CALL(IR_VOID, jit_STUB_FUNC_ADDR(jit, jit_stub_undefined_offset, IR_FASTCALL_FUNC));
}
ir_END_list(*end_inputs);
break;
case BP_VAR_IS:

View File

@@ -210,6 +210,15 @@ void ZEND_FASTCALL zend_jit_undefined_long_key(EXECUTE_DATA_D)
ZVAL_NULL(result);
}
void ZEND_FASTCALL zend_jit_undefined_long_key_ex(zend_long key EXECUTE_DATA_DC)
{
const zend_op *opline = EX(opline);
zval *result = EX_VAR(opline->result.var);
zend_error(E_WARNING, "Undefined array key " ZEND_LONG_FMT, key);
ZVAL_NULL(result);
}
void ZEND_FASTCALL zend_jit_undefined_string_key(EXECUTE_DATA_D)
{
const zend_op *opline = EX(opline);

View File

@@ -0,0 +1,16 @@
--TEST--
GH-15972 (Assertion failure in ext/opcache/jit/zend_jit_vm_helpers.c with function JIT)
--EXTENSIONS--
opcache
--FILE--
<?php
function test(){
for($i = 0; $i < 2; $i++){
$a = @[3][$i];
}
}
test();
?>
DONE
--EXPECT--
DONE