Skip to content

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Nov 8, 2024

Backport of #108380 and #109340 and #109826 to release/8.0-staging

Customer Impact

  • Customer reported
  • Found internally

Customers using RandomAccess.Write overload that accepts multiple buffers have observed IOException being thrown in two scenarios:

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

  • Yes
  • No

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.

NicoAvanzDev and others added 2 commits November 8, 2024 17:57
* 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 <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
@adamsitnik adamsitnik added Servicing-consider Issue for next servicing release review area-System.IO labels Nov 8, 2024
@adamsitnik adamsitnik added this to the 8.0.x milestone Nov 8, 2024
@adamsitnik adamsitnik self-assigned this Nov 8, 2024
@adamsitnik
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adamsitnik
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adamsitnik adamsitnik added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Nov 14, 2024
@adamsitnik
Copy link
Member Author

The failures are related, I am going to send a follow up PR to main and sync this branch soon

@jeffhandley jeffhandley removed the Servicing-consider Issue for next servicing release review label Nov 18, 2024
@jeffhandley
Copy link
Member

@adamsitnik I've removed the https://github.com/dotnet/runtime/labels/servicing-consider since you're still investigating the CI failures. Once it's ready for tactics review, please reapply the label.

Does this also need to be backported to release/9.0-staging?

* 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 <[email protected]>
# Conflicts:
#	src/libraries/System.IO.FileSystem/tests/RandomAccess/WriteGatherAsync.cs
@adamsitnik
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

This was referenced Aug 7, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants