1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix GH-13569: GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when scanning WeakMaps

This commit is contained in:
Arnaud Le Blanc
2024-03-02 12:32:10 +01:00
parent 6a3c083200
commit 6b57e2d988
2 changed files with 23 additions and 1 deletions

22
Zend/tests/gh13569.phpt Normal file
View File

@@ -0,0 +1,22 @@
--TEST--
GH-13569: GC buffer grows up to GC_MAX_BUF_SIZE when scanning WeakMaps
--FILE--
<?php
$wm = new WeakMap();
$objs = [];
for ($i = 0; $i < 30_000; $i++) {
$objs[] = $obj = new stdClass;
$wm[$obj] = $obj;
}
gc_collect_cycles();
$tmp = $wm;
$tmp = null;
gc_collect_cycles();
?>
==DONE==
--EXPECT--
==DONE==

View File

@@ -718,7 +718,7 @@ static void ZEND_FASTCALL gc_extra_root(zend_refcounted *ref)
if (EXPECTED(GC_HAS_UNUSED())) {
idx = GC_FETCH_UNUSED();
} else if (EXPECTED(GC_HAS_NEXT_UNUSED_UNDER_THRESHOLD())) {
} else if (EXPECTED(GC_HAS_NEXT_UNUSED())) {
idx = GC_FETCH_NEXT_UNUSED();
} else {
gc_grow_root_buffer();