mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-17577: JIT packed type guard crash
This commit is contained in:
@@ -1872,7 +1872,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
|
||||
if (!(orig_op1_type & IS_TRACE_PACKED)) {
|
||||
zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use];
|
||||
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)) {
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)
|
||||
&& (info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) {
|
||||
info->type |= MAY_BE_PACKED_GUARD;
|
||||
info->type &= ~MAY_BE_ARRAY_PACKED;
|
||||
}
|
||||
@@ -1881,7 +1882,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
|
||||
&& val_type != IS_UNDEF) {
|
||||
zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use];
|
||||
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)) {
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)
|
||||
&& (info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) {
|
||||
info->type |= MAY_BE_PACKED_GUARD;
|
||||
info->type &= ~(MAY_BE_ARRAY_NUMERIC_HASH|MAY_BE_ARRAY_STRING_HASH);
|
||||
}
|
||||
@@ -1965,7 +1967,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
|
||||
|
||||
zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use];
|
||||
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)) {
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)
|
||||
&& (info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) {
|
||||
info->type |= MAY_BE_PACKED_GUARD;
|
||||
if (orig_op1_type & IS_TRACE_PACKED) {
|
||||
info->type &= ~(MAY_BE_ARRAY_NUMERIC_HASH|MAY_BE_ARRAY_STRING_HASH);
|
||||
@@ -2067,7 +2070,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
|
||||
|
||||
zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use];
|
||||
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)) {
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)
|
||||
&& (info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) {
|
||||
info->type |= MAY_BE_PACKED_GUARD;
|
||||
if (orig_op1_type & IS_TRACE_PACKED) {
|
||||
info->type &= ~(MAY_BE_ARRAY_NUMERIC_HASH|MAY_BE_ARRAY_STRING_HASH);
|
||||
@@ -2097,7 +2101,8 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
|
||||
|
||||
zend_ssa_var_info *info = &tssa->var_info[tssa->ops[idx].op1_use];
|
||||
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)) {
|
||||
if (MAY_BE_PACKED(info->type) && MAY_BE_HASH(info->type)
|
||||
&& (info->type & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) {
|
||||
info->type |= MAY_BE_PACKED_GUARD;
|
||||
info->type &= ~MAY_BE_ARRAY_PACKED;
|
||||
}
|
||||
@@ -4236,10 +4241,13 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
|
||||
if ((info & MAY_BE_PACKED_GUARD) != 0
|
||||
&& (trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP
|
||||
|| trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_CALL
|
||||
|| trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_RET)
|
||||
|| (trace_buffer->stop == ZEND_JIT_TRACE_STOP_RECURSIVE_RET
|
||||
&& EX_VAR_TO_NUM((opline-1)->result.var) == i))
|
||||
&& (ssa->vars[i].use_chain != -1
|
||||
|| (ssa->vars[i].phi_use_chain
|
||||
&& !(ssa->var_info[ssa->vars[i].phi_use_chain->ssa_var].type & MAY_BE_PACKED_GUARD)))) {
|
||||
ZEND_ASSERT(STACK_TYPE(stack, i) == IS_ARRAY);
|
||||
|
||||
if (!zend_jit_packed_guard(&ctx, opline, EX_NUM_TO_VAR(i), info)) {
|
||||
goto jit_failure;
|
||||
}
|
||||
|
||||
27
ext/opcache/tests/jit/gh17577.phpt
Normal file
27
ext/opcache/tests/jit/gh17577.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
GH-17577 (JIT packed type guard crash)
|
||||
--EXTENSIONS--
|
||||
opcache
|
||||
--INI--
|
||||
opcache.jit_buffer_size=16M
|
||||
opcache.jit_hot_func=1
|
||||
--FILE--
|
||||
<?php
|
||||
$a = array(
|
||||
array(1,2,3),
|
||||
0,
|
||||
);
|
||||
function my_dump($var) {
|
||||
}
|
||||
foreach($a as $b) {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
my_dump($b[$i]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Trying to access array offset on int in %s on line %d
|
||||
|
||||
Warning: Trying to access array offset on int in %s on line %d
|
||||
|
||||
Warning: Trying to access array offset on int in %s on line %d
|
||||
Reference in New Issue
Block a user