v24: discarded vm contexts cause OOM; possible V8 backport
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js
- 領域
- backend
調査の方向性
repro.mjs から始め、v24 で --max-old-space-size=128 を付けて実行し、その後 v22、v26、v24 を --no-concurrent-recompilation 付きで比較します。IdentityMapBase の retainers と、関連する 2 つの V8 commit を調査し、それらが破棄された vm コンテキストに対処しているかどうかを判断します。再現コードがヒープを使い果たさずに "Completed" を出力し、破棄されたコンテキストを回収できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Version
v24.21.0
Platform
Linux x86_64, kernel 6.8.0-139-generic
Subsystem
vm, V8
What steps will reproduce the bug?
Save as repro.mjs; run node --max-old-space-size=128 repro.mjs.
import { runInNewContext } from "node:vm";
import { setImmediate } from "node:timers/promises";
const source = `
globalThis.payload = new Array(1_000_000).fill(0);
${Array.from({ length: 30 }, (_, index) => `
function work${index}(values) {
let result = 0;
for (let i = 0; i < values.length; ++i) {
result += Math.sqrt(values[i] * values[i] + ${index});
}
return result;
}
`).join("\n")}
const values = [1, 2, 3, 4, 5];
for (let i = 0; i < 1000; ++i) {
${Array.from({ length: 30 }, (_, index) => `work${index}(values);`).join("\n")}
}
`;
for (let i = 0; i < 100; ++i) {
runInNewContext(source + `\n// ${i}`);
await setImmediate();
}
console.log("Completed");
How often does it reproduce? Is there a required condition?
Repeatedly on v24.15.0, v24.16.0, and v24.21.0. Completes on v22.23.2, v26.8.2, or with --no-concurrent-recompilation on v24.
What is the expected behavior? Why is that the expected behavior?
Print Completed; discarded contexts should be collectible.
What do you see instead?
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Additional information
This surfaced in jsdom’s WPT runner with the default ~4 GB heap; the smaller limit makes this reproduction quick. Sampled heap retainers point through V8’s IdentityMapBase to realm prototypes, keeping entire windows alive.
Could V8’s “Stop collecting array and object prototypes” change be backported to v24? Its later thread-safety follow-up might also be relevant.
I haven't verified that those commits are the key ones, but it's worth trying.
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.4k
- 平均マージ
- 4日 4時間
- マージ済み PR(30日)
- 276
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nodejs/node のほかの issue
-
doc
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
build
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
似ている issue
-
bug customer-eng Durable Agents Inngest status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
optimization optimization:agents-md-curator
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
githubnext/gh-aw-cao#13475 ·
-
[BUG]: "Clear All" in Settings doesn't clear the saved analysis, old data comes back after reload オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
AOSSIE-Org/OrgExplorer#253 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
oxc-project/oxc#26944 ·
-
ai-observability bug team/ai-observability
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100