Bug#1016369: IO::Handle ->error does not work, always saying "fine"
Ian Jackson
ijackson at chiark.greenend.org.uk
Sat Jul 30 13:42:05 BST 2022
Package: perl
Version: 5.34.0-4
Severity: grave
To reproduce
perl -MIO::Handle -e 'open X, "<", "." or die $!; $_ = <X>; printf "%s %s %s\n", X->error(), $!;'
perl -MIO::Handle -e 'open X, ">", "/dev/full" or die $!; print X 1; flush X; printf "%s %s %s\n", X->error(), $!; close X'
Expected output
-1 Bad file descriptor
-1 No space left on device
Actual output
0 Bad file descriptor
0 No space left on device
This is quite alarming. I think it makes it in fact impossible to
read files fully reliably in Perl. "use autodie" does not seem to help.
And scripts might reasonably have expected that they could defer error
handling by testing error() rather than each call (as one can in C).
I think this used to work, but, evidently, only in the distant past,
since my jessie chroot doesn't get this right either.
Justification for the severity:
Can cause data loss: if a file is opened but unreadable for any
reason, the program will process the part (if any) that will is
readable and then
Ian.
--
Ian Jackson <ijackson at chiark.greenend.org.uk> These opinions are my own.
Pronouns: they/he. If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.
More information about the Perl-maintainers
mailing list