rust-lang / rust-lang/rust

write_all assumes that a write returning 0 is a kind of EOF

Open
#145,959 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-docs A-io T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The code is quite self-explaining:

https://github.com/rust-lang/rust/blob/a7e8fe73111a96871feadda1eefa2b3f616cdb8e/library/std/src/io/mod.rs#L1835-L1847

However, reading the write() docs, I see no justification for this. As far as I can tell, write is allowed to spuriously return 0 as a form of "short write". This random website also says so.

Cc @the8472

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with library/std/src/io/mod.rs at lines 1835-1847, then read the write() and write_all() documentation to compare their stated handling of zero-length writes. Check the existing standard-library I/O tests for coverage of this case; done means the behavior matches the documented contract and has a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.