Skip to content

Commit 786c14a

Browse files
committed
Fixes and improvements
* Actually skip non-cyclic objects in GC. * Add MAY_BE_CYCLIC to more internal classes * Fix dynamic property creation trigger And also breaking phpGH-10932 for now. :) I will try to fix this later.
1 parent 4eddbc5 commit 786c14a

File tree

5 files changed

+57
-48
lines changed

5 files changed

+57
-48
lines changed

Zend/zend_API.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
17701770
ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
17711771
}
17721772

1773+
GC_TYPE_INFO(object) &= ~(GC_NOT_COLLECTABLE << GC_FLAGS_SHIFT);
17731774
prop = zend_hash_update(zend_std_get_properties_ex(object), key, prop);
17741775
zval_add_ref(prop);
17751776
}
@@ -1782,6 +1783,7 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
17821783
ZSTR_VAL(object->ce->name), h);
17831784
}
17841785

1786+
GC_TYPE_INFO(object) &= ~(GC_NOT_COLLECTABLE << GC_FLAGS_SHIFT);
17851787
prop = zend_hash_index_update(zend_std_get_properties_ex(object), h, prop);
17861788
zval_add_ref(prop);
17871789
}
@@ -2443,7 +2445,10 @@ ZEND_API zend_result zend_startup_module_ex(zend_module_entry *module) /* {{{ */
24432445
Bucket *p;
24442446
ZEND_HASH_MAP_FOREACH_BUCKET_FROM(CG(class_table), p, prev_class_count) {
24452447
zend_class_entry *ce = Z_PTR(p->val);
2446-
if (ce->default_object_handlers->get_gc != zend_std_get_gc) {
2448+
if ((ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)
2449+
|| ce->create_object
2450+
|| ce->default_object_handlers->get_gc != zend_std_get_gc
2451+
|| ce->default_object_handlers->get_properties != zend_std_get_properties) {
24472452
ce->ce_flags |= ZEND_ACC_MAY_BE_CYCLIC;
24482453
}
24492454
} ZEND_HASH_FOREACH_END();

0 commit comments

Comments
 (0)