-
Notifications
You must be signed in to change notification settings - Fork 1.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
Dart crashes when stdout is closed prematurely #42989
Comments
In your example stdout is closed and it results in the underlying write returning an error (broken pipe) and this results in the exception being thrown. This appears to work as intended. Since there is no try/catch around the code the exception is propagated out as an unhandled exception. |
Because it's common for Unix pipes to close stdin early upon completing their tasks, the typical behavior for programming languages that try to write to a closed stdio stream is for the write to silently do nothing. Requiring every call to # None of these produces an error, despite stdout closing after the first line.
$ ruby -e 'puts "foo"; puts "bar"; puts "baz"' | grep -q foo
$ python -c 'print("foo"); print("bar"); print("baz")' | grep -q foo
$ node -e 'console.log("foo"); console.log("bar"); console.log("baz")' | grep -q foo Also, this is a breaking change that's breaking real code, including the Travis Dart configuration's built-in |
Yes, piling on to what @nex3 said: whether or not this is a bug, it is certainly a regression. Dart code that previously ran fine on the VM is now throwing an exception. At least some of that code happens to live inside a critical tool shipped with the Dart SDK (pub), and that tool itself is invoked by the CI used by many Dart packages in a way that triggers the crash. CC @jonasfj in case the pub folks want to workaround the regression. |
I'm I suppose we could workaround it with using a zone to intercept all calls to This sounds like the kind of thing that could have lots of negative side-effects whenever dart programs are used as a subprocess. |
Can you prioritize this? It's completely blocking our ability to verify formatting for any of our packages. |
Dart SDK version: 2.9.0
OS: Linux (Ubuntu Xenial on Travis and Debian Buster locally)
We discovered this when our dartfmt Travis tasks started failing (example job).
We initially thought it was an issue with the formatter, since our other Travis tasks were fine, but we ultimately released the issue was with this line in Travis's Dart script.
It tries to run
pub deps | grep -q <query> "^[|']-- dart_style "
and crashes when grep exits early when it finds the line in question.This can be replicated with the following minimal example:
Running
dart example.dart | grep -q a
results in:The
pub deps
version only started failing in 2.9.0 (2.8.4 works fine), but the example above also fails on 2.8.4.The text was updated successfully, but these errors were encountered: