Skip to content

Commit 38e0aca

Browse files
committed
Fix GH-22071: JIT assertion on abstract static method call.
The optimizer's ZEND_INIT_STATIC_METHOD_CALL handling returned the function entry even when the resolved method was abstract, leading the JIT to assert on a null address in jit_CONST_FUNC_PROTO when emitting a direct call (e.g. UnitEnum::cases()). close GH-22082
1 parent 3ec0670 commit 38e0aca

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
- CLI:
99
. Fixed bug GH-21901 (Stale getopt() optional value). (onthebed)
1010

11+
- Core:
12+
. Fixed bug GH-22071 (JIT assertion on abstract static method call).
13+
(David Carlier)
14+
1115
- Date:
1216
. Fixed bug GH-18422 (int overflow in php_date_llabs). (iliaal)
1317

Zend/Optimizer/zend_optimizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ zend_function *zend_optimizer_get_called_func(
945945
if (ce) {
946946
zend_string *func_name = Z_STR_P(CRT_CONSTANT(opline->op2) + 1);
947947
zend_function *fbc = zend_hash_find_ptr(&ce->function_table, func_name);
948-
if (fbc) {
948+
if (fbc && !(fbc->common.fn_flags & ZEND_ACC_ABSTRACT)) {
949949
bool is_public = (fbc->common.fn_flags & ZEND_ACC_PUBLIC) != 0;
950950
bool same_scope = fbc->common.scope == op_array->scope;
951951
if (is_public || same_scope) {

ext/opcache/tests/gh22071.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-22071: Assertion failure jit_CONST_FUNC_PROTO on abstract static method call
3+
--CREDITS--
4+
YuanchengJiang
5+
--EXTENSIONS--
6+
opcache
7+
--INI--
8+
opcache.enable=1
9+
opcache.enable_cli=1
10+
opcache.jit=1205
11+
opcache.jit_buffer_size=16M
12+
--FILE--
13+
<?php
14+
try {
15+
$e = enum_exists('UnitEnum') ? UnitEnum::cases() : [];
16+
} catch (\Throwable $_e) {}
17+
echo "ok\n";
18+
?>
19+
--EXPECT--
20+
ok

0 commit comments

Comments
 (0)