Ref counting based object release is not applied if cycle is broken in destructor during GC run
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
repro: https://3v4l.org/USrWu
see UPDATE below
It seems the GC can be improved. Currently, when a cycle is broken during GC run, a 2nd run of GC is needed to really release the object.
https://github.com/php/php-src/commit/b58d74547f "solves this issue" since PHP 8.2+, but is that the most efficient solution for everything? If a cycle (all cycles/references to an object) is explicitly broken during GC, is there anything againts releasing that object by standard refcounting?
Resulted in this output:
d
gc
bool(true) <- notice object is kept alive after the destructor has broken the cycle (and refcount dropped to 0)
gc rerun
bool(false)
bool(false)
done
But I expected this output instead:
d
gc
bool(false)
gc rerun
bool(false)
bool(false)
done
UPDATE:
Based on https://3v4l.org/mgoqd I would call this a bug as 2nd WeakReference::get() call is expected to always give the same result if no GC is run in between the calls.
PHP Version
any (tested PHP 7.4, 8.3)
Operating System
any
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず https://3v4l.org/USrWu で再現を実行し、https://3v4l.org/mgoqd の更新された例と比較してください。GC、デストラクタ、参照カウント、WeakReference::get() に注目します。GC の実行中に切断された循環によってオブジェクトが直ちに解放され、2 回目の GC の実行なしに両方の WeakReference のチェック結果が期待される出力と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100