You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assertion failure in Zend/zend_weakrefs.c:646 #16371
Is the class also problematic when backed by arrays? (new ArrayObject([]))
I've seen it used as pass-by-ref arrays. Until now I was convinced this was the primary use-case, and that objects support had been added because "why not". Looking at the history, it was added in 173cb1436fb5 ("Add class spl_array which is an array wrapper"). It was originally named spl_array, but later renamed ArrayClass, and ultimately ArrayObject.
If that part is relatively sane, can we just discourage the use of objects as backing store?
Good point @arnaud-lb! I guess you're right, and there are no general issues when wrapping arrays (and also about the history of the class, and especially the "why not" comment). Thus, I've just submitted php/doc-en#3867.
@arnaud-lb , I am facing the similar kind of assertion failure here
php: /usr/src/php/Zend/zend_weakrefs.c:547: zend_weakmap_get_object_key_entry_gc: Assertion `zv' failed in php 8.5 alpha2.
DO we need to fix the issue here as well and validate zv before zend_assert ?
@arnaud-lb ,I am finding a hard time to find a reproducer for this case. However this is only getting generated for my extension in PHP 8.5 alpha2.
Basically , The assertion ZEND_ASSERT(zv) is failing, which means zv is NULL. This happens when the function zend_hash_index_find() doesn't find the key obj_key in the hash table wm->ht.
and I am assuming this is likely happening because during garbage collection, PHP is trying to clean up weak references, but it's encountering an object that has been removed from the weak reference map
Activity
ndossche commentedon Oct 11, 2024
See also #15775 (comment)
IMO We should just yeet this class ASAP
cmb69 commentedon Oct 11, 2024
See php/doc-en#3858 (a humble first step).
arnaud-lb commentedon Oct 14, 2024
Is the class also problematic when backed by arrays? (
new ArrayObject([]))I've seen it used as pass-by-ref arrays. Until now I was convinced this was the primary use-case, and that objects support had been added because "why not". Looking at the history, it was added in 173cb1436fb5 ("Add class spl_array which is an array wrapper"). It was originally named spl_array, but later renamed ArrayClass, and ultimately ArrayObject.
If that part is relatively sane, can we just discourage the use of objects as backing store?
Restrict discouragement of ArrayObject to wrapping objects
cmb69 commentedon Oct 14, 2024
Good point @arnaud-lb! I guess you're right, and there are no general issues when wrapping arrays (and also about the history of the class, and especially the "why not" comment). Thus, I've just submitted php/doc-en#3867.
Fix handling of invalid iterator in zend_weakmap_iterator_get_current…
Restrict discouragement of ArrayObject to wrapping objects (GH-3867)
HeenaBansal20 commentedon Jul 29, 2025
@arnaud-lb , I am facing the similar kind of assertion failure here
php: /usr/src/php/Zend/zend_weakrefs.c:547: zend_weakmap_get_object_key_entry_gc: Assertion `zv' failed in php 8.5 alpha2.
DO we need to fix the issue here as well and validate zv before zend_assert ?
arnaud-lb commentedon Jul 30, 2025
@HeenaBansal20 are you able to provide a small reproducer code snippet?
HeenaBansal20 commentedon Jul 30, 2025
@arnaud-lb ,I am finding a hard time to find a reproducer for this case. However this is only getting generated for my extension in PHP 8.5 alpha2.
Basically , The assertion ZEND_ASSERT(zv) is failing, which means zv is NULL. This happens when the function zend_hash_index_find() doesn't find the key obj_key in the hash table wm->ht.
and I am assuming this is likely happening because during garbage collection, PHP is trying to clean up weak references, but it's encountering an object that has been removed from the weak reference map