node:fs: calling writeFileSync/appendFileSync with negative 0 causes an assertion failure
Đang mở
Chưa có ai nhận issue này.
fs
- Ngôn ngữ chính
- JavaScript
- Star
- 122k
- Fork
- 37.4k
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 272
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại src/node_file.cc, xung quanh assertion WriteFileUtf8 được báo cáo ở dòng 2764, bằng cách sử dụng các trường hợp tái hiện writeFileSync(-0, "") và appendFileSync(-0, ""). Theo dõi cách các API fs xử lý đối số path và thêm coverage cho số không âm; hoàn thành khi cả hai lệnh gọi đều không bị abort và đều hoạt động như số không dương.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, node.js
- Lĩnh vực
- backend, operating-systems
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 65/100