Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

vm: eval cache mixes up script origins

未關閉
#65,866 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
cpp, javascript, node.js
領域
backend

研究方向

使用提供的 test.mjs 在 --experimental-vm-modules 下重現問題,然後檢查 deps/v8/src/codegen/compiler.cc 中 "cache lookup key" 註解附近的程式碼。追蹤 eval 快取查找和相關測試,以了解指令碼來源是如何表示的。啟用編譯快取後 A/B/A 斷言通過,同時現有的無編譯快取行為仍然正確,即表示完成。

由索引模型根據 Issue 內容生成。

描述

Bug report

  • Node.js: v24.19.0, v26.8.1, v27.0.0-pre (local build)
  • Platform: Microsoft Windows NT 10.0.26200.0 x64
  • Subsystem: vm
// test.mjs
import assert from 'node:assert/strict';
import { Script } from 'node:vm';

const out = [];

function createScript(name) {
  return new Script(`globalThis.eval('import("node:fs")')`, {
    importModuleDynamically(specifier) {
      out.push(name);
      return import(specifier);
    },
  });
}

const a = createScript('A');
const b = createScript('B');

for (const script of [a, b, a]) {
  await script.runInThisContext();
}

assert.deepEqual(out, ['A', 'B', 'A']);

Running this example as node --experimental-vm-modules test.mjs will give different wrong answers between v24 and v26 because V8 removed delayed caching some time during those releases. However, running with --no-compilation-cache will pass the test assertion.

The bug is with V8. In deps/v8/src/codegen/compiler.cc, around the "cache lookup key" comment, indirect eval uses kNoSourcePosition (-1), and the cache key does not distinguish the originating script. This allows identical eval source text from different scripts in the same realm to produce a false positive cache hit.

主要語言
JavaScript
星號
122k
分支
38.4k
平均合併
3 天 22 小時
30 天內合併 PR
273

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。