Skip to content

Commit ffc7e95

Browse files
committed
properties_info_table may be in arena or shm
For immutable classes it should be shm instead of in arena. Related to bug #77615.
1 parent c62e106 commit ffc7e95

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

ext/opcache/tests/preload.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ trait T2 {
3737
class Y {
3838
use T2;
3939
}
40+
41+
class Z {
42+
public $foo;
43+
}

ext/opcache/zend_persist.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,13 @@ static void zend_persist_class_entry(zval *zv)
874874
int i;
875875

876876
size_t size = sizeof(zend_property_info *) * ce->default_properties_count;
877-
memcpy(ZCG(arena_mem), ce->properties_info_table, size);
878-
ce->properties_info_table = ZCG(arena_mem);
879-
ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(size));
877+
if (ZCG(is_immutable_class)) {
878+
ce->properties_info_table = zend_shared_memdup_put(
879+
ce->properties_info_table, size);
880+
} else {
881+
ce->properties_info_table = zend_shared_memdup_arena_put(
882+
ce->properties_info_table, size);
883+
}
880884

881885
for (i = 0; i < ce->default_properties_count; i++) {
882886
ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry(ce->properties_info_table[i]);

ext/opcache/zend_persist_calc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static void zend_persist_class_entry_calc(zval *zv)
388388
zend_hash_persist_calc(&ce->properties_info, zend_persist_property_info_calc);
389389

390390
if (ce->properties_info_table) {
391-
ADD_ARENA_SIZE(sizeof(zend_property_info *) * ce->default_properties_count);
391+
ADD_SIZE_EX(sizeof(zend_property_info *) * ce->default_properties_count);
392392
}
393393

394394
if (ce->num_interfaces) {

0 commit comments

Comments
 (0)