-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
ICE on "rustc --help | false" #34376
Comments
Yields an ICE when you pipe with |
Cannot replicate on Windows inside Powershell. |
Yes, this ICE happens always when the pipe for output is broken. You can reproduce this by piping rustc output to whatever command which exits before consuming all of the rustc’s output. For example: |
Backtrace:
|
I wonder if there is overlap between this and #14505 (which was closed because the problem stopped occurring for |
Same thing happened for me when I tried to pipe the AST into something that failed
|
Copying from #36415. So investigating this leads me to believe that we're handling something incorrectly here: Line 691 in 77f1bec
|
Another option would be to remove the "we would appreciate a bug report" line if the behaviour is intended. |
Simply terminating successfully (
In both cases, This is a common issue when writing shell utilities that produce output the user might pipe to a program that does not read all of the output, e.g. |
Prevent broken pipes causing ICEs As the private `std::io::print_to` panics if there is an I/O error, which is used by `println!`, the compiler would ICE if one attempted to use a broken pipe (e.g. `rustc --help | false`). This introduces a new (private) macro `try_println!` which allows us to avoid this. As a side note, it seems this macro might be useful publicly (and actually there seems to be [a crate specifically for this purpose](https://crates.io/crates/try_print/)), though that can probably be left for a future discussion. One slight alternative approach would be to simply early exit without an error (i.e. exit code `0`), which [this comment](rust-lang#34376 (comment)) suggests is the usual approach. I've opted not to take that approach initially, because I think it's more helpful to know when there is a broken pipe. Fixes rust-lang#34376.
Thank you @varkor for fixing this! |
Minimal steps to reproduce:
rustc --help | false
.Yields an ICE. Tested in latest nightly (2016-06-15) as well as on latest stable(1.9.0).
The text was updated successfully, but these errors were encountered: