Collecting WeakMap keys requires multiple GC passes
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- c
調査の方向性
Start with the attached weakmap_gc_repro.c and run it using the build commands in the issue to confirm both cases. Then trace QuickJS's WeakMap and weak-reference handling in the GC; the issue does not name source files or tests, so locate the relevant code and existing GC tests. Done means the self-referencing key is collected and the chain of keys is freed after a fixed number of GC passes.
索引モデルが issue の本文から書いたものです。
説明
Issue
I think I've found two bugs related to weak references / WeakMap handling by the GC.
(1) An entry whose value references its own key is never collected while the WeakMap is alive.
/* Case 1: the value references its own key. */
(function () {
var key = {};
map.set(key, { backRef: key });
globalThis.selfRef = new WeakRef(key);
})();
Expected result:
keyis collected after one pass of the GC
Actual result:
keyis never collected by the GC but should be collected on the first pass.
(2) A chain of entries (each value references the next entry's key) takes n JS_RunGC() calls to free
/* Case 2: a chain of 20 entries; each value references the next key. */
(function () {
var key = {};
for (var i = 0; i < 20; i++) {
var next = {};
map.set(key, { child: next });
key = next;
}
globalThis.chainTail = new WeakRef(key);
})();
Expected result:
- All 20 keys is collected after a fixed number (ideally one) passes of the GC.
Actual result:
- Collecting
nkeys appears to requirenpasses of the GC.
Repro
Here's a program that reproduces the issue. Compile it like this:
quickjs $ make libquickjs.a
quickjs $ cc -O2 -I. weakmap_gc_repro.c libquickjs.a -lm -lpthread -o weakmap_gc_repro
quickjs $ ./weakmap_gc_repro
- 主要言語
- C
- スター
- 11.1k
- フォーク
- 1.2k
- 平均マージ
- 11時間 20分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bellard/quickjs のほかの issue
-
難易度 4/5 1〜2日 初心者へのやさしさ 48/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 58/100
bellard/quickjs#575 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
メンテナーはふだん 3 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
bellard/quickjs#559 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
Security findings: BigInt interrupt-bypass CPU DoS (verified) and 5 other issues — commit 04be246オープン
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
メンテナーはふだん 3 日以内に返信
bellard/quickjs の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
epics-base/epics-base#1034 ·
メンテナーはふだん 2 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信