diff --git a/Zend/tests/gh22520.phpt b/Zend/tests/gh22520.phpt new file mode 100644 index 000000000000..e5b7ba26169a --- /dev/null +++ b/Zend/tests/gh22520.phpt @@ -0,0 +1,32 @@ +--TEST-- +GH-22520: Lazy object OOM should not crash zend_lazy_object_del_info +--SKIPIF-- + +--INI-- +memory_limit=2M +--FILE-- +newLazyGhost(function ($obj) {}); + $reflector->getProperty('a')->setRawValueWithoutLazyInitialization($obj, $obj); + } +} catch (Throwable $e) { + echo "Caught: " . $e->getMessage() . "\n"; +} + +?> +--EXPECTF-- +Fatal error: Allowed memory size of %d bytes exhausted %s in %s on line %d diff --git a/Zend/zend_lazy_objects.c b/Zend/zend_lazy_objects.c index a8316768ef5f..31927385b6e9 100644 --- a/Zend/zend_lazy_objects.c +++ b/Zend/zend_lazy_objects.c @@ -161,7 +161,7 @@ zend_lazy_object_flags_t zend_lazy_object_get_flags(const zend_object *obj) void zend_lazy_object_del_info(const zend_object *obj) { zend_result res = zend_hash_index_del(&EG(lazy_objects_store).infos, obj->handle); - ZEND_ASSERT(res == SUCCESS); + ZEND_ASSERT(res == SUCCESS || CG(unclean_shutdown)); } bool zend_lazy_object_decr_lazy_props(const zend_object *obj)