Nonsense UNKNOWN error when writing large buffers with fs.writev
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
Version
14.18.1
Platform
Linux ops 5.11.0-1021-gcp #23~20.04.1-Ubuntu SMP Fri Oct 1 19:04:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linu
Subsystem
fs
What steps will reproduce the bug?
const fs = require("fs");
const fd = fs.openSync("./test.dat", fs.constants.O_WRONLY | fs.constants.O_CREAT, 0o666);
const bufs = [Buffer.alloc(0x7FFFFFFF + 1)];
fs.writevSync(fd, bufs, 0);
This throws
Uncaught Error: UNKNOWN: unknown error, write
at Object.writevSync (fs.js:749:3) {
errno: -2147483648,
syscall: 'write',
code: 'UNKNOWN'
}
That errno is 0x7fffffff + 1 wrapped around.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Should either work, since pwritev(2) works (I don't know if it has a limit less than SSIZE_MAX), or report a proper error before making the syscall. I did the latter recently for fs.write in c4e7dca8f30ff89b42e96fb8819558ed518a72dd. It would be nice if large files actually worked, but the best fix for that would require a new libuv function.
What do you see instead?
No response
Additional information
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 fs.js 中的 fs.writevSync 开始,将其参数处理与提交 c4e7dca8f30ff89b42e96fb8819558ed518a72dd 所引用的 fs.write 验证进行比较。在 Linux 上复现大缓冲区情况,然后确定最终行为应在 syscall 之前以适当的错误拒绝请求,还是应通过 libuv 支持更大的缓冲区。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend, operating-systems
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100