php / php-src

The PHP Interpreter
https://www.php.net
Other
38.1k stars 7.74k forks source link

Assertion failure in Zend/zend_gc.c #15943

Open YuanchengJiang opened 1 month ago

YuanchengJiang commented 1 month ago

Description

The following code:

<?php
$wm = new WeakMap();
for ($i = 0; $i < 30_000; $i++) {
$fusion[] = $obj = new stdClass;
$wm[$obj] = $obj;
}
$tmp = $wm;
$tmp = null;
gc_collect_cycles();

Resulted in this output:

/php-src/Zend/zend_gc.c:791: gc_remove_from_buffer: Assertion `idx' failed.
Aborted (core dumped)

To reproduce:

-d "memory_limit=8M"

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

cmb69 commented 1 month ago

For me, this script outputs:

Fatal error: Allowed memory size of 8388608 bytes exhausted at Zend\zend_gc.c:2141 (tried to allocate 1048608 bytes) in %s on line %d
Assertion failed: idx, file Zend\zend_gc.c, line 791
cmb69 commented 3 weeks ago

PHP-8.3 (and maybe lower branches) exhibit the same behavior.