[release/6.0.1] Support async operations on unseekable files #61410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a manual backport of #58434, the problem has been recently discussed for #60931 which has not been merged to 6.0 as it was simply too late.
Customer Impact
This PR actually fixes two bugs.
The first one is a bug reported by customer via email, where an async read operation performed on a
FileStream
opened for non-seekable device file was throwing anSystem.IO.IOException
: "The parameter is incorrect".It turns out that
ReadFile
doc was wrong:And
OVERLAPPED
doc was right:The second bug is #58383. To tell the long story short,
File.ReadAllBytes*(string path, ...)
methods were assuming thatpath
can't point to a non-seekable file like named pipe.Testing
The fix was verified using tests added in the PR. It has been in main for a month (#58434) and we have already been doing that for sync file handles (the issue was originally discovered and fixed by @stephentoub):
runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs
Lines 723 to 732 in cf7d517
Risk
Very low.