-
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
[release/9.0-staging] Fix few RandomAccess.Write edge case bugs #109646
base: release/9.0-staging
Are you sure you want to change the base?
[release/9.0-staging] Fix few RandomAccess.Write edge case bugs #109646
Conversation
* add test for Int32 overflow for WriteGather in RandomAccess * add failing test fore more than IOV_MAX buffers * fix both the native and managed parts --------- Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
Tagging subscribers to this area: @dotnet/area-system-io |
/azp list |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@adamsitnik did you want to port the same test fixes to this PR that you mentioned in #109648? |
|
Ok, please add back servicing-consider when it's ready. |
* don't run these tests in parallel, as each test cases uses more than 4 GB ram and disk! * fix the test: handle incomplete reads that should happen when we hit the max buffer limit * incomplete write fix: - pin the buffers only once - when re-trying, do that only for the actual reminder * Use native memory to get OOM a soon as we run out of memory (hoping to avoid the process getting killed on Linux when OOM happens) * For macOS preadv and pwritev can fail with EINVAL when the total length of all vectors overflows a 32-bit integer. * add an assert that is going to warn us if vector.Count is ever more than Int32.MaxValue --------- Co-authored-by: Michał Petryka <35800402+MichalPetryka@users.noreply.github.com>
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
Backport of #108380 and #109340 and #109826 to release/9.0-staging
Customer Impact
Customers using
RandomAccess.Write
overload that accepts multiple buffers have observedIOException
being thrown in two scenarios:Int32
) overflows and the method tries to perform a write with negative file offset. Reported by the user in RandomAccess.Write throws System.IO.IOException: The parameter is incorrect. #108322.IOV_MAX
(usually 1024). Reported by the user in RandomAccess.Write throws System.IO.IOException: Invalid argument when buffers count is greater than 1024 #108383.When I was fixing #108383 I've realized that the logic for handling incomplete writes has a bug.
For incomplete multi-buffer writes, the API was not reporting any exceptions. It returns void, so it should write everything or throw an exception.
Regression
We had all 3 bugs since the API was introduced (.NET 6).
Testing
New unit tests were added. They were failing before the fix were applied. They are passing now.
Risk
Low, the fix is simple and covered with tests.