Non-suspended generators in suspended Fiber do not participate in GC
オープン
まだ誰も着手していません。
Bug
Category: Engine
Category: Fibers
Category: GC
Category: Generators
Status: Verified
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Found this while checking if https://github.com/php/php-src/issues/9916 also happened during GC.
The following code:
<?php
class Canary {
public function __construct(
public readonly string $x,
) {
}
public function __destruct() {
var_dump($this->x);
}
}
$gen = (function() {
$canary = new Canary('Generator dtor');
$fiber = yield;
Fiber::suspend();
})();
$fiber = new Fiber(function() use ($gen, &$fiber) {
$canary = new Canary('Fiber dtor');
$gen->send($fiber);
});
$fiber->start();
$gen = null;
$fiber = null;
gc_collect_cycles();
var_dump('Shutdown');
Resulted in this output:
string(8) "Shutdown"
string(14) "Generator dtor"
string(10) "Fiber dtor"
But I expected this output instead:
string(14) "Generator dtor"
string(10) "Fiber dtor"
string(8) "Shutdown"
PHP Version
PHP 8.1
Operating System
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された PHP 8.1 の再現コードを実行し、gc_collect_cycles() 中の Fiber と Generator のライフサイクルを追跡します。中断された Fiber が保持している中断されていない Generator がガベージコレクションにどのように関与するかを調査します。完了条件は、"Shutdown" の出力前に両方のデストラクタが実行されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100