Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

println!() does not panic when STDOUT returns ENOSPC #78753

Closed
GoldsteinE opened this issue Nov 4, 2020 · 3 comments
Closed

println!() does not panic when STDOUT returns ENOSPC #78753

GoldsteinE opened this issue Nov 4, 2020 · 3 comments
Labels
A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@GoldsteinE
Copy link
Contributor

GoldsteinE commented Nov 4, 2020

I tried this code:

fn main() {
    println!("Hello, world!")
}

running it as cargo run > /dev/full or equivalent.

I expected to see this happen: as STDOUT is now "full" and write() syscall returns ENOSPC, println!() should panic, as per documentation.

Instead, this happened: println!() silently did nothing. Process returned 0 exit code.

Meta

Bug happens on stable, but is (probably) fixed on nightly
rustc --version --verbose:

rustc 1.47.0 (18bf6b4f0 2020-10-07)
binary: rustc
commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
commit-date: 2020-10-07
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0
@GoldsteinE GoldsteinE added the C-bug Category: This is a bug. label Nov 4, 2020
@GoldsteinE
Copy link
Contributor Author

GoldsteinE commented Nov 4, 2020

Also, as a kinda-unrelated note: checking for EBADF in stdio_raw methods (introduced in #26168) not only prevents println!() from panicking on closed fd, but also prevents user of io::stdout() methods from handling errors.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d125440454e0485ef8566428bc404624
IMO, this code should panic, as it explicitly panics on I/O error and I/O error occurs here.

@jyn514 jyn514 added A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 5, 2020
@sfackler
Copy link
Member

sfackler commented Nov 5, 2020

I can confirm that it's fixed on nightly, though I'm not sure from looking at the code what was actually going wrong on 1.47.0.

@masklinn
Copy link
Contributor

masklinn commented May 9, 2021

ENOSPC definitely triggers on 1.52 stable, so this can probably be closed.

@sfackler sfackler closed this as completed May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-bug Category: This is a bug. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants