Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Make zero-length Unix stream reads return without blocking or reporting EOF

未关闭 适合新手
#990 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
90/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
linux, rust

调研方向

从 std/net/unix.wave 中的 unix_read 开始,将其零大小处理方式与 TCP 和向量读取辅助函数进行比较。保留现有的大小和缓冲区验证,并在请求的大小为零时,在执行任何 OS 读取之前返回一个计数为零且非 EOF 的成功结果。添加一个 socketpair 回归测试,覆盖空流、排队数据和对端关闭,并在 O0 和 O2 下验证结果。

由索引模型根据 Issue 内容生成。

描述

bug good first 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wavefnd/Wave 的其他 Issue

查看 wavefnd/Wave 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。