com php-src: properties_info_table may be in arena or shm: ext/opcache/tests/preload.inc ext/opcache/ zend_persist.c ext/opcache/zend_persist_calc.c
| From: | Nikita Popov | Date: | Fri, 15 Feb 2019 09:27:30 +0000 |
| Subject: | com php-src: properties_info_table may be in arena or shm: ext/opcache/tests/preload.inc ext/opcache/ zend_persist.c ext/opcache/zend_persist_calc.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104651@lists.php.net to get a copy of this message | ||
Commit: ffc7e953ea908f05703d573faadc51707936321c
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 10:26:46 +0100
Parents: c62e1066103f7a126c8b7e1247d89cac2d230cc0
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ffc7e953ea908f05703d573faadc51707936321c
Log:
properties_info_table may be in arena or shm
For immutable classes it should be shm instead of in arena.
Related to bug #77615.
Bugs:
https://bugs.php.net/77615
Changed paths:
M ext/opcache/tests/preload.inc
M ext/opcache/zend_persist.c
M ext/opcache/zend_persist_calc.c
Diff:
diff --git a/ext/opcache/tests/preload.inc b/ext/opcache/tests/preload.inc
index af20c49..0e09ad3 100644
--- a/ext/opcache/tests/preload.inc
+++ b/ext/opcache/tests/preload.inc
@@ -37,3 +37,7 @@ trait T2 {
class Y {
use T2;
}
+
+class Z {
+ public $foo;
+}
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index 188c31e..d22b855 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -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]);
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index 21f6d45..7daac7b 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -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) {