Skip to content

Commit 6d6cd29

Browse files
committed
Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3
2 parents 35aef8e + 10d912d commit 6d6cd29

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ PHP NEWS
2929
- Opcache:
3030
. Fixed GH-13508 (JITed QM_ASSIGN may be optimized out when op1 is null).
3131
(Arnaud, Dmitry)
32+
. Fixed GH-13712 (Segmentation fault for enabled observers when calling trait
33+
method of internal trait when opcache is loaded). (Bob)
3234

3335
- Random:
3436
. Fixed bug GH-13544 (Pre-PHP 8.2 compatibility for mt_srand with unknown

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,9 +1993,9 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
19931993
} else {
19941994
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
19951995
memcpy(new_fn, fn, sizeof(zend_op_array));
1996-
new_fn->op_array.fn_flags |= ZEND_ACC_TRAIT_CLONE;
19971996
new_fn->op_array.fn_flags &= ~ZEND_ACC_IMMUTABLE;
19981997
}
1998+
new_fn->common.fn_flags |= ZEND_ACC_TRAIT_CLONE;
19991999

20002000
/* Reassign method name, in case it is an alias. */
20012001
new_fn->common.function_name = name;

ext/opcache/tests/gh13712.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-13712 (Segmentation fault for enabled observers when calling trait method of internal trait when opcache is loaded)
3+
--EXTENSIONS--
4+
opcache
5+
zend_test
6+
--INI--
7+
zend_test.observer.enabled=1
8+
opcache.enable=1
9+
opcache.enable_cli=1
10+
--FILE--
11+
<?php
12+
class Foo {
13+
use _ZendTestTrait;
14+
}
15+
16+
$f = new Foo();
17+
var_dump($f->testMethod());
18+
?>
19+
--EXPECTF--
20+
<!-- init '%s' -->
21+
<!-- init Foo::testMethod() -->
22+
<!-- init var_dump() -->
23+
bool(true)

ext/opcache/zend_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ static void zend_persist_class_method(zval *zv, zend_class_entry *ce)
729729
}
730730
// Real dynamically created internal functions like enum methods must have their own run_time_cache pointer. They're always on the same scope as their defining class.
731731
// However, copies - as caused by inheritance of internal methods - must retain the original run_time_cache pointer, shared with the source function.
732-
if (!op_array->scope || op_array->scope == ce) {
732+
if (!op_array->scope || (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE))) {
733733
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
734734
}
735735
}

0 commit comments

Comments
 (0)