[release/8.0-staging] Fix few RandomAccess.Write edge case bugs by adamsitnik · Pull Request #109648 · dotnet/runtime

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 <3840695+am11@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>

This was referenced

Nov 8, 2024

@adamsitnik

stephentoub

@adamsitnik adamsitnik added the NO-MERGE

The PR is not ready for merge yet (see discussion for detailed reasons)

label

Nov 14, 2024

@adamsitnik @MichalPetryka

* 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>
# Conflicts:
#	src/libraries/System.IO.FileSystem/tests/RandomAccess/WriteGatherAsync.cs

This was referenced

Dec 12, 2024

This was referenced

Aug 7, 2025