vm: eval cache mixes up script origins
維護者通常 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
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`可能已有人在做 @lazerg 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
build / doc: missing platform and toolchain info for `linux-x64-musl`可能已有人在做 @theSnackOverflow 於 1 天前認領。 未關閉alpine build doc
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 於 10 天前認領。 未關閉doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 於 11 天前認領。 未關閉doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
build
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
相似的 Issue
-
macOS
難度 2/5 1-3 小時 新手友好度 76/100
beyondcode/herd-community#1761 ·
-
content good first issue hacktoberfest
難度 2/5 1-3 小時 新手友好度 74/100
vieanderes/understory#19 ·
-
automated issue report
難度 2/5 1-3 小時 新手友好度 68/100
lirantal/discoprint#37 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
tauri-apps/tauri#16219 ·
維護者通常 2 天內回覆
-
agentic-workflows
難度 1/5 1 小時以內 新手友好度 90/100
githubnext/gh-aw-cao#16599 ·
維護者通常 1 天內回覆