-
Notifications
You must be signed in to change notification settings - Fork 553
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
IO::Handle::error() can lose read errors #20060
Comments
|
Another way to exercise this behaviour is this I looked through (IHNI what |
|
In Debian 1016369, Damyan Ivanov provided this test program (which I've renamed with the two bug report numbers): The program fails, but in different ways, on both Linux and FreeBSD. Linux (Ubuntu 20.04 LTS) FreeBSD (version 12) So our definition of the problem, as well as our solution and the tests we use to verify that solution, will have an OS-specific component. |
And, FWIW, it fails differently with different versions of Perl. On perl-5.32 and earlier, on Linux I get test failures in tests 2 and 5 just as I do on FreeBSD. On perl-5.34 I only get a failure in test 5. Bisecting points to the following commit as causing the improvement. I don't yet understand exactly how this relates to the OP's problem. |
The referenced Debian report discusses both a read error issue and a write error issue. The /dev/full test is for the write error issue. I believe it was #6799 and got fixed in 5.34. The read error issue is what I filed this bug about. Hope this clarifies. |
I expect it's fixable, but might cause other changes in behaviour, I tried: which allowed one of your test cases to pass (I didn't try the others): but caused a test failure I don't have time to track down right now. |
As reported by Ian Jackson in https://bugs.debian.org/1016369 IO::Handle::error() can report 0 when there was an error on the filehandle.
A test case is
perl -MIO::Handle -e 'open X, "<", "." or die $!; $_ = <X>; printf "%s %s\n", X->error(), $!;'which returns "0 Is a directory" for me on Linux although all reads on the filehandle fail with EISDIR.
I've debugged this a bit and it looks like the error gets cleared in Perl_do_readline() around pp_hot.c:3295 or so with a PerlIO_clearerr() call. I think this is related to reading past EOF or something like that?
While trying to treat a directory as a regular file is something of a corner case (and the result is rather platform dependent), Ian argues that this is an indication of a more general problem where EIO and similar errors can go unnoticed if user code is relying on the IO::Handle::error() method to report them. Of course, creating simple test cases for such errors is difficult if not impossible.
I see #12782 is very similar but hasn't really received much attention. Is this something that should at least be documented as a caveat if it's not fixable?
The text was updated successfully, but these errors were encountered: