zend_types.h:1383: zend_gc_delref: Assertion `p->refcount > 0' failed upon memory exhaustion
還沒有人認領這個 Issue。
評估
研究方向
首先,使用回報中的偵錯建置和記憶體限制執行所提供的 PHP 重現程式。檢查第 356 行的 Zend/zend_gc.c 和第 1383 行的 zend_types.h,然後將行為與 issue #16835 進行比較。當記憶體耗盡回報 fatal error,且不會觸發 refcount assertion 或 abort 時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Description
The following code:
<?php
class Node {
public $parent = NULL;
public $children = array();
function __construct(?Node $parent=NULL) {
if ($parent) {
$parent->children[] = $this;
}
$this->children[] = $this;
}
function __destruct() {
$this->children = NULL;
}
}
define("MAX", 16);
for ($n = 0; $n < 20; $n++) {
$top = new Node();
for ($i=0 ; $i<MAX ; $i++) {
$ci = new Node($top);
for ($j=0 ; $j<MAX ; $j++) {
$cj = new Node($ci);
for ($k=0 ; $n ?? (0 >> $i) & $n ?? $n ?? 20 ?? MAX<MAX ; $k++) {
$ck = new Node($cj);
}
}
}
echo "$n\n";
}
echo "ok\n";
?>
Resulted in this output:
0
Fatal error: Allowed memory size of 97517568 bytes exhausted at /home/user/software/php-debug-noasan/src/Zend/zend_gc.c:356 (tried to allocate 4096 bytes) in /tmp/bug.php on line 27
Stack trace:
#0 {main}
php: /home/user/software/php-debug-noasan/src/Zend/zend_types.h:1383: zend_gc_delref: Assertion `p->refcount > 0' failed.
Aborted (core dumped)
But I expected this output instead:
Fatal error: Allowed memory size of 97517568 bytes exhausted at /home/user/software/php-debug-noasan/src/Zend/zend_gc.c:356 (tried to allocate 4096 bytes) in /tmp/bug.php on line 27
This bug seems to be dependent on how much memory you give php, through grid searching I found these values of memory trigger the bug
93M, 94M, 127M, 128M, 159M, 160M, 193M-196M, 243M-248M, 287M-290M, 333M-338M, 383M-390M
Looks very similar to https://github.com/php/php-src/issues/16835 but unsure about same root cause
PHP Version
PHP 8.5.10 (cli) (built: Sep 5 2026 19:25:14) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.5.10, Copyright (c) Zend Technologies
with Zend OPcache v8.5.10, Copyright (c), by Zend Technologies
34308a6666b2d489c509541ea9befea9e2b42348
Operating System
Ubuntu 24.04
- 主要語言
- C
- 星號
- 40.4k
- 分支
- 8.2k
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 113
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
php/php-src 的其他 Issue
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 76/100
-
Bug Status: Needs Triage
難度 1/5 1 小時以內 新手友好度 90/100
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 78/100
-
Bug Category: Tests Status: Verified
難度 2/5 1-3 小時 新手友好度 68/100
-
Bug SAPI: fpm Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 65/100
相似的 Issue
-
task
難度 2/5 1-3 小時 新手友好度 70/100
vsanthanam/JBird#429 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
-
bug documentation
難度 2/5 1-3 小時 新手友好度 75/100
es-ude/OnDeviceTraining#459 ·
-
難度 2/5 1-3 小時 新手友好度 65/100
bilelmoussaoui/gobject-linter#199 · 1 則留言 ·
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
bradcypert/plum#53 ·