Fix GH-17866: zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4#17880
Fix GH-17866: zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4#17880ndossche wants to merge 5 commits intophp:PHP-8.4from
Conversation
…4.3 to 8.4.4 This regressed in phpGH-17592. The function is with its attributes HashTable* is copied in zend_get_closure_invoke_method() but its refcount is not increased. This caused a crash in the Symfony demo page.
|
@dstogov While reviewing #17914 I started wondering why we need to refcount the attributes on trampolines in the first place. The attributes always come from a real function created by the compiler. So it seems to me that the real function, with its attributes, always lives longer than the trampoline. diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 277430ce102..efcb7fd5ed3 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1618,12 +1618,7 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
| ZEND_ACC_PUBLIC
| ZEND_ACC_VARIADIC
| (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED));
- if (fbc->common.attributes) {
- func->attributes = fbc->common.attributes;
- GC_TRY_ADDREF(func->attributes);
- } else {
- func->attributes = NULL;
- }
+ func->attributes = fbc->common.attributes;
if (is_static) {
func->fn_flags |= ZEND_ACC_STATIC;
}
diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h
index 2fc59d5020c..c7348a74245 100644
--- a/Zend/zend_object_handlers.h
+++ b/Zend/zend_object_handlers.h
@@ -339,10 +339,6 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
} while (0)
#define zend_free_trampoline(func) do { \
- HashTable *attributes = (func)->common.attributes; \
- if (attributes && !(GC_FLAGS(attributes) & GC_IMMUTABLE) && !GC_DELREF(attributes)) { \
- zend_array_destroy(attributes); \
- } \
if ((func) == &EG(trampoline)) { \
EG(trampoline).common.attributes = NULL; \
EG(trampoline).common.function_name = NULL; \
The code becomes a bit simpler. |
I think, you are right. We also don't increment reference-counter of |
This regressed in GH-17592.
The function is with its attributes HashTable* is copied in zend_get_closure_invoke_method() but its refcount is not increased. This caused a crash in the Symfony demo page.