-
Notifications
You must be signed in to change notification settings - Fork 577
only clear the stream error state in readline() for a good nextargv() #20103
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
Conversation
The code change looks good but what I'm missing:
For that last one: |
I never include perldelta updates in PRs - they're almost guaranteed to conflict with other updates to perldelta. But I could talk about it here, maybe something like:
This is reasonable, I'll look at it.
I don't see a way to do that, since the error is only cleared for nextargv() we'd need to populate |
2a6080f
to
66be8f4
Compare
Doing some more testing: On my system reading from /dev/ttyS3: open succeeds, read fails:
So open succeeds, read fails so that is a good test case. Testing with my own fh: old perl:
your PR:
blead without
So that looks good. Testing with ARGV: old perl:
your PR:
blead without
No change in behaviour.
Which really means: as far as I can tell you can't check if reading from ARGV failed by using So again I'm at the state where I don't see when TLDR: I (still) question if/when doing a |
After writing the previous message I started wondering about something else: why does Old messageAgain testing with /dev/ttyS3 (where open succeeds but read fails with EIO):
So according to that I would expect that
The From
=>
The question: would one expect that a failed Update doing some more testing shows the same behavior when writing to a file. So applying the same behavior to read looks OK. Write exampleUsing a tmpfs of 1M:
Note:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I still wonder if/when PerlIO_clearerr
is needed but that shouldn't hold back this PR)
This would previously clear the stream error state in any case where sv_gets() failed and the error state was set. This included normal files, which meant that the fact that an error occurred was no longer reflected in the stream state. For reads from ARGV this was a no-op, since nextargv() re-opens the input stream by calling do_open6() which closes the old input stream silently. For glob() (and really only for miniperl, since File::Glob is used for a full perl) leaving the stream in an error state could be confusing for the error reporting done when do_close() fails, since it would fail if the stream has an error state, but we report it as the underlying pclose() failing due to the child process failing in some way. Since this now leaves the error state on the stream, the close() calls in the test updated by this commit would fail, changing its output. Since the result of those closes didn't seem related to the purpose of the test, I changed it not throw an error on either close() failing.
66be8f4
to
e85654c
Compare
Looking at the flow through that code, do_open6() and nextargv() it looks like the clearerr() is only needed for globs:
Note that the implicit close warning is only ever produced for an IO object going out of scope, not for a file reopened:
I've re-worked it to only clear the error for glob(), which I think is correct(-ish), but should only have an effect for |
On Thu, 18 Aug 2022 at 02:39, Tony Cook ***@***.***> wrote:
- a perldelta entry (I'm not sure when these are normally added):
perl's own test suite was "impacted" by the bug fix so it's
possible(/likely?) other code out there will be too; so I think it
certainly should be mentioned in perldelta
I never include perldelta updates in PRs - they're almost guaranteed to
conflict with other updates to perldelta.
IMO it would be nice to have a solution to that. If perldeltas changes were
added as new filelets and assembled later it might make people more
inclined to add new perldeltas. That would avoid any conflicts and make it
easier to see what changes came from what PR's.
Eg, instead of changing perldelta you create perldelta_20103.pod, it
contains the delta changes from PR #20103, this one. When we do the release
process we construct perldelta from the pieces.
cheers,
Yves
…--
perl -Mre=debug -e "/just|another|perl|hacker/"
|
Do you have an example of when it's needed? |
I don't see a specific case - it would have to be read() failing before sv_gets() has read anything, and the cases where read() fails where we don't otherwise handle it (EINTR can happen and is handled). On POSIX systems I don't think it can happen unless something else is badly wrong, none of EAGAIN, EFAULT, EBADF, EIO, EISDIR should happen. It might be different on non-POSIX systems. |
This patches load_configs() to check that the $config being opened is actually a file and not a directory, which was tripping up the tests that assert that there is an error when the config file cannot be written because a directory already exists. Until recently, the attempt to read the directory as a file was being silently ignored due to a latent bug in Perl; more about that here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1016369 and Perl/perl5#20103 This addresses a bug filed against the Debian package for clusterssh when t/15config.t tests started failing after the Perl bug was fixed. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1026735
This would previously clear the stream error state in any case
where sv_gets() failed and the error state was set.
Since this now leaves the error state on the stream, the close()
calls in the test updated by this commit would fail, changing its
output. Since the result of those closes didn't seem related
to the purpose of the test, I changed it not throw an error on
either close() failing.
Fixes #20060