Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Zend/tests/gh22520.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-22520: Lazy object OOM should not crash zend_lazy_object_del_info
--SKIPIF--
<?php
if (!getenv('RUN_RESOURCE_HEAVY_TESTS')) die('skip resource-heavy test');
if (getenv('SKIP_SLOW_TESTS')) die('skip slow test');
if (PHP_INT_SIZE != 8) die('skip 64-bit only');
?>
--INI--
memory_limit=2M
--FILE--
<?php

class C {
public $a;
}

$str = str_repeat('a', 1024 * 1024 * 1.25);

try {
$reflector = new ReflectionClass(C::class);
for ($i = 0; $i < 10000; $i++) {
$obj = $reflector->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
2 changes: 1 addition & 1 deletion Zend/zend_lazy_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading