You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As part of programm startup, the Crystal runtime initializes handles for the three standard streams.
If such a stream is already closed, the runtime crashes.
This affects any Crystal program which uses STDINsomehow (i.e. the constant is initialized).
A minimal reproduction is crystal <&- (the shell redirection <&- instructs that stdin is to be closed). This results in the following error:
Unhandled exception: Unable to get info: Bad file descriptor (IO::Error)
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in 'raise<IO::Error>:NoReturn'
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in 'Crystal::System::FileDescriptor::system_info<Int32>:File::Info'
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in 'IO::FileDescriptor::new<Int32>:IO::FileDescriptor'
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in 'IO::FileDescriptor::from_stdio<Int32>:IO::FileDescriptor'
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in '__crystal_main'
from /opt/homebrew/Cellar/crystal/1.12.1_1/bin/crystal in 'main'
The same error does not appear when passing a closed output file descriptor (crystal >&-).
I'm not sure how to reproduce in pure Crystal yet. Passing a closed IO to Process.run errors on the invoking process (Closed stream from Process#copy_io). This needs to be fixed as well.
Interestingly, Process::Redirect::Close does not actually close the file descriptor. It only passes the null device (i.e. it's equivalent to crystal < /dev/null).
A closed file descriptor equivalent to the shell redirection apparently <&- has different semantics.
As part of programm startup, the Crystal runtime initializes handles for the three standard streams.
If such a stream is already closed, the runtime crashes.
This affects any Crystal program which uses
STDIN
somehow (i.e. the constant is initialized).A minimal reproduction is
crystal <&-
(the shell redirection<&-
instructs that stdin is to be closed). This results in the following error:The same error does not appear when passing a closed output file descriptor (
crystal >&-
).I'm not sure how to reproduce in pure Crystal yet. Passing a closed
IO
toProcess.run
errors on the invoking process (Closed stream
fromProcess#copy_io
). This needs to be fixed as well.This was originally reported in https://forum.crystal-lang.org/t/unable-to-get-info-bad-file-descriptor-io-error/6820
The text was updated successfully, but these errors were encountered: