Skip to content

Commit a1eaaa6

Browse files
committed
Fix #79475: [JIT] func_get_args() assertion violation
`func_get_args()` may return `zend_empty_array`, which has refcount 2 to enforce separation. We have to cater to that during type inference so that the optimization in the JIT macro `SEPARATE_ARRAY` doesn't prevent the separation.
1 parent 7a260a4 commit a1eaaa6

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static const func_info_t func_infos[] = {
9393
/* zend */
9494
F1("zend_version", MAY_BE_STRING),
9595
FN("func_get_arg", UNKNOWN_INFO),
96-
F1("func_get_args", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
96+
FN("func_get_args", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY),
9797
F1("get_class_vars", MAY_BE_FALSE | MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
9898
FN("get_object_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),
9999
FN("get_mangled_object_vars", MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF),

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ static zend_always_inline int _zend_update_type_info(
34653465
UPDATE_SSA_TYPE(MAY_BE_LONG, ssa_op->result_def);
34663466
break;
34673467
case ZEND_FUNC_GET_ARGS:
3468-
UPDATE_SSA_TYPE(MAY_BE_RC1| MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def);
3468+
UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN| MAY_BE_ARRAY | MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_OF_ANY, ssa_op->result_def);
34693469
break;
34703470
case ZEND_GET_CLASS:
34713471
case ZEND_GET_CALLED_CLASS:

ext/opcache/tests/bug79475.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #79475 ([JIT] func_get_args() assertion violation)
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
function foo() {
8+
$args = func_get_args();
9+
$args[] = "bar";
10+
}
11+
foo();
12+
echo "done\n";
13+
?>
14+
--EXPECT--
15+
done

0 commit comments

Comments
 (0)