diff --git a/Zend/tests/weakrefs/weakmap_dtor_exception.phpt b/Zend/tests/weakrefs/weakmap_dtor_exception.phpt new file mode 100644 index 00000000000..97249285cf6 --- /dev/null +++ b/Zend/tests/weakrefs/weakmap_dtor_exception.phpt @@ -0,0 +1,18 @@ +--TEST-- +Exception during WeakMap destruction during shutdown +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Exception: Test in %s:%d +Stack trace: +#0 [internal function]: class@anonymous->__destruct() +#1 {main} + thrown in %s on line %d diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index b08e9734391..ad20c4cabd3 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -157,8 +157,8 @@ void zend_weakrefs_notify(zend_object *object) { ZEND_ASSERT(tagged_ptr && "Tracking of the IS_OBJ_WEAKLY_REFERENCE flag should be precise"); #endif if (tagged_ptr) { - zend_weakref_unref(obj_addr, tagged_ptr); zend_hash_index_del(&EG(weakrefs), obj_addr); + zend_weakref_unref(obj_addr, tagged_ptr); } }