-
Notifications
You must be signed in to change notification settings - Fork 13k
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
check for broken pipe when streaming the output. #11850
Conversation
For instance, if we give command: $rust | xargs -v we get, xargs: illegal option -- v usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr] [-L number] [-n number [-x]] [-P maxprocs] [-s size] [utility [argument ...]] error: internal compiler error: unexpected failure This message reflects a bug in the Rust compiler. We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html note: the compiler hit an unexpected failure path. this is a bug task '<main>' failed at 'Unhandled condition: io_error: io::IoError{kind: BrokenPipe, desc: "broken pipe", detail: None}', /Users/abhay/devel/rust/rust/src/ The BrokenPipe (or EPIPE) occurs when the receiving-end process returns non-zero exit-status. This patch checks if raised condition is not BrokenPipe, and if not, it raises the condition.
Fixing this issue is certainly a good idea, but I'm not sure this is the right approach. What you've done here hides all EPIPE errors for stdout/stderr. Being able to detect that stdout has been closed is a valid thing to want to be able to do, but you can't do that anymore with this. Additionally, this only hides it for stdout/stderr. It doesn't try to suppress EPIPE for any other file handles. I'm not sure what the practical solution here is. Ideally, anything that writes to stdout/stderr would handle io_errors, because crashing rustc due to a stdout issue (including, but not limited to, EPIPE) seems less than ideal. But practically speaking, I don't know how much effort it would take to find every location in rustc that would need to be updated. My understanding is that I/O functions were slated to stop using conditions and start using proper return values. If this happens, then that would be a good time to add correct handling of things like this, since all stdout writing would need to be updated anyway. Unfortunately the relevant ticket, #10449, has already been closed so I'm not quite sure what the status of this is. @alexcrichton, any idea? |
Hm, I'm not entirely sure what we should do about this. We're trying to promote "no unused results" everywhere, so migrating this to conditions won't fix anything. What'll happen is that It does seem odd to ignore all EPIPE errors, I can imagine that there's a legitimate use-case somewhere for seeing it. On the other hand it seems odd that we print a failure message on a broken pipe. I'll have to think a little more on this. |
@alexcrichton It's already a condition, which is why we print the failure message. My understanding is that we're going to be migrating I/O to returning a On that note, if we're going to advocate calling |
Hi guys, thanks for the comments. I would like to work on this issue. Could you please tell me what i should do? |
Here's what I found from some other languages
Sounds like it's pretty standard to be expected to deal with this in the code itself (rather than ignoring the error). Closing because it seems like this is normal behavior. |
[`deprecated_semver`]: Allow `#[deprecated(since = "TBD")]` "TBD" is allowed by rustdoc, saying that it will be deprecated in a future version. rustc will also not actually warn on it. I found this while checking the rust-lang/rust with clippy. changelog: [`deprecated_semver`]: allow using `since = "TBD"`
For instance, if we give command:
we get,
The
BrokenPipe
(orEPIPE
) occurs when the receiving-end process returns non-zero exit-status.I tested raising the condition with following
C
code:The above code returns 1 after reading everything from the piped process.
The commands i executed:
The last command gave the
unexpected failure
error.This patch checks if raised condition is not BrokenPipe, and otherwise, it raised the condition.