Skip to content

Commit 9bed0b5

Browse files
committed
Merge branch 'PHP-8.3'
2 parents f47b7f1 + 6d6cd29 commit 9bed0b5

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,9 +1996,9 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
19961996
} else {
19971997
new_fn = zend_arena_alloc(&CG(arena), sizeof(zend_op_array));
19981998
memcpy(new_fn, fn, sizeof(zend_op_array));
1999-
new_fn->op_array.fn_flags |= ZEND_ACC_TRAIT_CLONE;
20001999
new_fn->op_array.fn_flags &= ~ZEND_ACC_IMMUTABLE;
20012000
}
2001+
new_fn->common.fn_flags |= ZEND_ACC_TRAIT_CLONE;
20022002

20032003
/* Reassign method name, in case it is an alias. */
20042004
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
@@ -730,7 +730,7 @@ static void zend_persist_class_method(zval *zv, zend_class_entry *ce)
730730
}
731731
// 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.
732732
// However, copies - as caused by inheritance of internal methods - must retain the original run_time_cache pointer, shared with the source function.
733-
if (!op_array->scope || op_array->scope == ce) {
733+
if (!op_array->scope || (op_array->scope == ce && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE))) {
734734
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
735735
}
736736
}

0 commit comments

Comments
 (0)