node:fs: calling writeFileSync/appendFileSync with negative 0 causes an assertion failure
未关闭
还没有人认领这个 Issue。
fs
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
Version
v26.8.1
Platform
Linux nixdesk 6.18.48 #1-NixOS SMP PREEMPT_DYNAMIC Fri Aug 28 06:22:54 UTC 2026 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
require("node:fs").writeFileSync(-0, "")
or
require("node:fs").appendFileSync(-0, "")
How often does it reproduce? Is there a required condition?
it always happens on my machine. i have not tried on any other computer or os
What is the expected behavior? Why is that the expected behavior?
for it to do the same thing as positive zero i assume
What do you see instead?
❯ echo 'require("node:fs").writeFileSync(-0, "")' | node -
# node[264400]: void node::fs::WriteFileUtf8(const v8::FunctionCallbackInfo<v8::Value>&) at ../../src/node_file.cc:2764
# Assertion failed: (*path) != nullptr
----- Native stack trace -----
1: 0x629c801c0228 [node]
2: 0x629c801c0b97 node::Assert(node::AssertionInfo const&) [node]
3: 0x629c801cda7b [node]
4: 0x729babdcfae9
----- JavaScript stack trace -----
1: writeFileSync (node:fs:2997:20)
2: [stdin]:1:20
3: runScriptInThisContext (node:internal/vm:219:10)
4: node:internal/process/execution:485:12
5: [stdin]-wrapper:6:24
6: runScriptInContext (node:internal/process/execution:483:60)
7: evalFunction (node:internal/process/execution:317:30)
8: evalTypeScript (node:internal/process/execution:329:3)
9: node:internal/main/eval_stdin:51:5
10: node:internal/process/execution:239:5
fish: Job 1, 'echo 'require("node:fs").writeF…' terminated by signal SIGABRT (Abort)
Additional information
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 src/node_file.cc 中第 2764 行报告的 WriteFileUtf8 断言附近开始,使用 writeFileSync(-0, "") 和 appendFileSync(-0, "") 进行复现。跟踪 fs API 如何处理 path 参数,并为负零添加覆盖;完成的标准是两个调用都不会中止,并且行为都与正零一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend, operating-systems
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 65/100