Make zero-length Unix stream reads return without blocking or reporting EOF
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 90/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- linux, rust
调研方向
从 std/net/unix.wave 中的 unix_read 开始,将其零大小处理方式与 TCP 和向量读取辅助函数进行比较。保留现有的大小和缓冲区验证,并在请求的大小为零时,在执行任何 OS 读取之前返回一个计数为零且非 EOF 的成功结果。添加一个 socketpair 回归测试,覆盖空流、排队数据和对端关闭,并在 O0 和 O2 下验证结果。
由索引模型根据 Issue 内容生成。
描述
Problem
unix_read always calls recv and interprets a zero result as EOF, even when the caller requested zero bytes. On Linux a zero-length recv on an empty blocking stream can wait for data; once data is queued it returns zero, which Wave incorrectly labels as peer closure. The TCP result and vectored helpers already distinguish zero-sized requests.
Starting point: unix_read.
Reproduction
Audited canonical master 540728c2eb6cc12f5c69c3fb3fdb96e07ba059a4 on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, matching checkout std, Rust 1.89.0 and LLVM 21.1.8. Compile this at O0 and O2:
import("std::net::unix")::{UnixStream,unix_read};
import("std::net::error")::{NetIoResult};
fun main() -> i32 {
var r: NetIoResult = unix_read(UnixStream { fd: 3 }, null, 0);
println("count={} eof={} kind={}", r.count, r.eof, r.error.kind);
return 0;
}
Execute from Python with an inherited local socketpair (descriptor 3 in this minimal harness):
import socket, subprocess
left, right = socket.socketpair()
try:
assert left.fileno() == 3
right.send(b'x')
result = subprocess.run(['./repro'], pass_fds=(3,), capture_output=True,
text=True, timeout=2)
print(result.stdout)
print(left.recv(1))
finally:
left.close()
right.close()
Both optimization levels print count=0 eof=1 kind=10; the subsequent Python read still receives b'x' and the peer was never closed. Omitting the send made the subprocess hit the two-second timeout. No external communication was used.
Scope
Preserve invalid-size/buffer validation, then return a successful zero-count, non-EOF result without an OS read for size zero. Keep EOF behavior for nonempty reads after real peer closure. Difficulty: small localized change with a real socketpair regression.
Completion criteria
- Zero-length reads return immediately with count 0, eof false and no error on an open empty stream.
- Null buffers are allowed for zero bytes; negative sizes and nonempty null buffers remain invalid.
- Queued data is preserved and real nonempty EOF still reports EOF at O0/O2.
- 主要语言
- Rust
- 星标
- 56
- 派生
- 21
- 平均合并
- 10 小时 10 分钟
- 30 天内合并 PR
- 52
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
wavefnd/Wave 的其他 Issue
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
build good first issue
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
discussion enhancement help wanted
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
discussion enhancement help wanted
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
desktop documentation
难度 1/5 1 小时以内 新手友好度 90/100
vfarcic/dot-agent-deck#2008 ·
维护者通常 1 天内回复
-
L: javascript
难度 2/5 1-3 小时 新手友好度 72/100
dependabot/dependabot-core#16744 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
nautechsystems/nautilus_trader#5486 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Bump rustls-webpki, webpki-roots and webpki-root-certs for the emSign distrust (CVE-2026-111943)未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复