properties_info_table may be in arena or shm
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 15 Feb 2019 09:26:46 +0000 (10:26 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 15 Feb 2019 09:27:30 +0000 (10:27 +0100)
For immutable classes it should be shm instead of in arena.

Related to bug #77615.

ext/opcache/tests/preload.inc
ext/opcache/zend_persist.c
ext/opcache/zend_persist_calc.c

index af20c4947f8a7fb0058219c34501a07fd6401091..0e09ad366c3191206cddffd6da2965492f1d89e0 100644 (file)
@@ -37,3 +37,7 @@ trait T2 {
 class Y {
        use T2;
 }
+
+class Z {
+    public $foo;
+}
index 188c31ea3140339df5eedbf29f23cfc1d3edcdc8..d22b855f5889ab4e5bc3cea80d06bed9dad1136c 100644 (file)
@@ -874,9 +874,13 @@ static void zend_persist_class_entry(zval *zv)
                        int i;
 
                        size_t size = sizeof(zend_property_info *) * ce->default_properties_count;
-                       memcpy(ZCG(arena_mem), ce->properties_info_table, size);
-                       ce->properties_info_table = ZCG(arena_mem);
-                       ZCG(arena_mem) = (void*)((char*)ZCG(arena_mem) + ZEND_ALIGNED_SIZE(size));
+                       if (ZCG(is_immutable_class)) {
+                               ce->properties_info_table = zend_shared_memdup_put(
+                                       ce->properties_info_table, size);
+                       } else {
+                               ce->properties_info_table = zend_shared_memdup_arena_put(
+                                       ce->properties_info_table, size);
+                       }
 
                        for (i = 0; i < ce->default_properties_count; i++) {
                                ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry(ce->properties_info_table[i]);
index 21f6d45b5b259b67b68d095cfe0c594a9a78c598..7daac7b51cf0a7c5418e76664335204c7861f405 100644 (file)
@@ -388,7 +388,7 @@ static void zend_persist_class_entry_calc(zval *zv)
                zend_hash_persist_calc(&ce->properties_info, zend_persist_property_info_calc);
 
                if (ce->properties_info_table) {
-                       ADD_ARENA_SIZE(sizeof(zend_property_info *) * ce->default_properties_count);
+                       ADD_SIZE_EX(sizeof(zend_property_info *) * ce->default_properties_count);
                }
 
                if (ce->num_interfaces) {