Repository navigation
MemoryStream_CapacityBoundaryChecks fails with OutOfMemoryException #119839
Description
Activity
- addedKnown Build ErrorUse this to report build issues in the .NET Helix tabUse this to report build issues in the .NET Helix tab
on Sep 18, 2025 - addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Sep 18, 2025 - addedneeds-area-labelAn area label is needed to ensure this gets routed to the appropriate area ownersAn area label is needed to ensure this gets routed to the appropriate area owners
on Sep 18, 2025 - added and removedneeds-area-labelAn area label is needed to ensure this gets routed to the appropriate area ownersAn area label is needed to ensure this gets routed to the appropriate area owners
on Sep 19, 2025 dotnet-policy-service commented
on Sep 19, 2025 ContributorMore actionsTagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.- removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Sep 19, 2025 Likely would be "fixed" if we implemented dotnet/xharness#1473
I've updated the error messge to
[FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecksas the previous one didn't catch all the errors on the CI. Sometimes we get[18:10:31] dbug: 2025-10-07 18:10:31.810815-0400 System.IO.Tests[34420:503380] [FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecks [18:10:31] dbug: Assert.Throws() Failure: No exception was thrown [18:10:31] dbug: Expected: typeof(System.ArgumentOutOfRangeException) [18:10:31] dbug: 2025-10-07 18:10:31.810972-0400 System.IO.Tests[34420:503380]or
[18:33:31] dbug: 2025-10-07 15:33:15.371668-0700 0x1898c76 Default 0x0 20462 0 System.IO.Tests: [FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecks [18:33:31] dbug: System.OutOfMemoryException : Insufficient memory to continue the execution of the program. [18:33:31] dbug: at System.IO.MemoryStream.set_Capacity(Int32 value)I think runtime throws a wrong exception. It comes from this place in the
AllocateSzArray:
runtime/src/coreclr/vm/gchelpers.cpp
Lines 640 to 641 in 8bfc105
if ((SIZE_T)cElements > MaxArrayLength()) ThrowOutOfMemoryDimensionsExceeded(); I believe array allocation should throw
ArgumentOutOfRangeExceptionas the test checks when the requested size is larger than the maximum index. TheOutOfMemoryExceptionshould be thrown only when the requested size is in range, but the allocation failed.@jkotas am I right?
I believe array allocation should throw ArgumentOutOfRangeException as the test checks when the requested size is larger than the maximum index.
This has thrown OutOfMemoryException with a custom message since forever. Changing it would be a breaking change.
I believe that this failure was introduced by #119089 and fixed by #120091. We are not seeing any more hits:
24-Hour Hit Count 7-Day Hit Count 1-Month Count 0 0 0 Closing
- locked and limited conversation to collaborators
on Dec 27, 2025
Build Information
Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1151114
Build error leg or test failing: MemoryStream_CapacityBoundaryChecks
Error Message
Fill the error message using step by step known issues guidance.
{ "ErrorMessage": "[FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecks", "BuildRetry": false, "ExcludeConsoleLog": false }The test failed for me even locally on Windows (the build above is on Android). The exact failure is:
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1151114
Error message validated:
[Expected: typeof(System.ArgumentOutOfRangeException)]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/18/2025 9:43:39 AM UTC
Report
Summary
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1151114
Error message validated:
[MemoryStream_CapacityBoundaryChecks Expected: typeof(System.ArgumentOutOfRangeException)]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/18/2025 5:15:01 PM UTC
Report
Summary
Report
Summary
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1151114
Error message validated:
[[FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecks]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 10/8/2025 7:34:34 AM UTC
Report
Summary
Report
Summary
Report
Summary