Skip to content

Commit ee2c0d7

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix phpGH-18639: Internal class aliases can break preloading + JIT
2 parents eb78a0b + 8e731ca commit ee2c0d7

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ PHP NEWS
2121
- MbString:
2222
. Fixed bug GH-18901 (integer overflow mb_split). (nielsdos)
2323

24+
- Opcache:
25+
. Fixed bug GH-18639 (Internal class aliases can break preloading + JIT).
26+
(nielsdos)
27+
2428
- Standard:
2529
. Fix misleading errors in printf(). (nielsdos)
2630

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3302,8 +3302,16 @@ int zend_jit_script(zend_script *script)
33023302
|| JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
33033303
zend_class_entry *ce;
33043304
zend_op_array *op_array;
3305+
zval *zv;
3306+
3307+
ZEND_HASH_MAP_FOREACH_VAL(&script->class_table, zv) {
3308+
if (Z_TYPE_P(zv) == IS_ALIAS_PTR) {
3309+
continue;
3310+
}
3311+
3312+
ce = Z_PTR_P(zv);
3313+
ZEND_ASSERT(ce->type == ZEND_USER_CLASS);
33053314

3306-
ZEND_HASH_MAP_FOREACH_PTR(&script->class_table, ce) {
33073315
ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) {
33083316
if (!ZEND_FUNC_INFO(op_array)) {
33093317
void *jit_extension = zend_shared_alloc_get_xlat_entry(op_array->opcodes);

ext/opcache/tests/gh18639.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-18639 (Internal class aliases can break preloading + JIT)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit=1255
7+
opcache.jit_buffer_size=16M
8+
opcache.preload={PWD}/preload_gh18567.inc
9+
--EXTENSIONS--
10+
opcache
11+
--SKIPIF--
12+
<?php
13+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
14+
?>
15+
--FILE--
16+
<?php
17+
echo "ok\n";
18+
?>
19+
--EXPECT--
20+
ok

0 commit comments

Comments
 (0)