-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
RandomAccess.Write throws System.IO.IOException: The parameter is incorrect. #108322
Comments
Tagging subscribers to this area: @dotnet/area-system-io |
This is not a regression, because RandomAccess.Write was added in .NET 6.0.0, where it already uses the wrong type in runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs Lines 408 to 419 in 4822e3c
RandomAccess.Read does not have a similar bug; there, RandomAccess.ReadScatterAtOffset correctly uses |
I think the buggy WriteGatherAtOffset can also silently write to the wrong offset and thus corrupt the file, if the |
@miroslavp thank you for a detailed bug report. You are right, it's a bug. Since you have found the place that requires the fix, would you like to send a PR with a fix? |
I've opened a pull request with the fix for this issue. Let me know if it's ok for you guys. Thanks you all ! |
Thank you, but I prefer not to. I don't feel confident enough to do that. If you guys can fix it, that would be awesome. |
I've created a PR with the fix and performed testing on it #108380. Hope this can be appreciated ! Thanks guys for your job ! |
Description
RandomAccess.Write(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset)
throwsIOException
on Windows platform when the bytes in thebuffers
list exceedInt32.MaxValue
Here's the relevant stack trace
I suspect the problem is in the
bytesWritten
variable, because it isint
and it overflowsruntime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs
Lines 435 to 446 in 01aa3d9
Reproduction Steps
Just call RandomAccess.Write(handle, buffers, 0) on Windows machine where
buffers
parameter contains multipleReadOnlyMemory<byte>
buffers that collectively are larger than 2GBExpected behavior
It should save the buffers to the file and not throw IOException
Actual behavior
throws System.IO.IOException: The parameter is incorrect.
Regression?
Haven't tried it on .NET 6
Known Workarounds
I guess you can split the buffers in multiple smaller lists and call the method multiple times
Configuration
Which version of .NET is the code running on?
.NET 7
What OS and version, and what distro if applicable?
Windows 10
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
I believe the problem is in the Windows implementation only
Other information
No response
The text was updated successfully, but these errors were encountered: