Skip to content

MemoryStream_CapacityBoundaryChecks fails with OutOfMemoryException #119839

Description

@vitek-karas

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:

Assert.Throws() Failure: Exception type was not an exact match
Expected: typeof(System.ArgumentOutOfRangeException)
Actual:   typeof(System.OutOfMemoryException)

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

Build Definition Test Pull Request
1151853 dotnet/runtime System.Numerics.Tests.modpowTest.RegressionIssuePerformance2575 #119846
1151627 dotnet/runtime System.IO.Tests.WorkItemExecution
1151114 dotnet/runtime System.IO.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 3 3

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

Build Definition Test Pull Request
1151853 dotnet/runtime System.Numerics.Tests.modpowTest.RegressionIssuePerformance2575 #119846
1151627 dotnet/runtime System.IO.Tests.WorkItemExecution
1151114 dotnet/runtime System.IO.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 3 3

Report

Build Definition Test Pull Request
1167858 dotnet/runtime System.IO.Tests.WorkItemExecution
1167605 dotnet/runtime System.IO.Tests.WorkItemExecution #120462
1167270 dotnet/runtime System.IO.Tests.WorkItemExecution
1166867 dotnet/runtime System.IO.Tests.WorkItemExecution
1166378 dotnet/runtime System.IO.Tests.WorkItemExecution
1166120 dotnet/runtime System.IO.Tests.WorkItemExecution
1165989 dotnet/runtime System.IO.Tests.WorkItemExecution
1165833 dotnet/runtime System.IO.Tests.WorkItemExecution
1165507 dotnet/runtime System.IO.Tests.WorkItemExecution
1165234 dotnet/runtime System.IO.Tests.WorkItemExecution
1165079 dotnet/runtime System.IO.Tests.WorkItemExecution #120374
1164609 dotnet/runtime System.IO.Tests.WorkItemExecution
1164127 dotnet/runtime System.IO.Tests.WorkItemExecution
1163522 dotnet/runtime System.IO.Tests.WorkItemExecution
1163156 dotnet/runtime System.IO.Tests.WorkItemExecution
1162437 dotnet/runtime System.IO.Tests.WorkItemExecution
1162003 dotnet/runtime System.IO.Tests.WorkItemExecution
1161477 dotnet/runtime System.IO.Tests.WorkItemExecution
1161044 dotnet/runtime System.IO.Tests.WorkItemExecution
1160492 dotnet/runtime System.IO.Tests.WorkItemExecution
1160225 dotnet/runtime System.IO.Tests.WorkItemExecution
1160091 dotnet/runtime System.IO.Tests.WorkItemExecution
1159967 dotnet/runtime System.IO.Tests.WorkItemExecution
1159811 dotnet/runtime System.IO.Tests.WorkItemExecution
1159546 dotnet/runtime System.IO.Tests.WorkItemExecution
1159087 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1159003 dotnet/runtime System.IO.Tests.WorkItemExecution
1158922 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1158508 dotnet/runtime System.IO.Tests.WorkItemExecution
1158133 dotnet/runtime System.IO.Tests.WorkItemExecution #106880
1158053 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1157808 dotnet/runtime System.IO.Tests.WorkItemExecution
1157349 dotnet/runtime System.IO.Tests.WorkItemExecution
1156839 dotnet/runtime System.IO.Tests.WorkItemExecution
1156363 dotnet/runtime System.IO.Tests.WorkItemExecution
1155882 dotnet/runtime System.IO.Tests.WorkItemExecution
1155421 dotnet/runtime System.IO.Tests.WorkItemExecution
1154724 dotnet/runtime System.IO.Tests.WorkItemExecution
1154346 dotnet/runtime System.IO.Tests.WorkItemExecution
1154137 dotnet/runtime System.IO.Tests.WorkItemExecution
1154038 dotnet/runtime System.IO.Tests.WorkItemExecution
1153847 dotnet/runtime System.IO.Tests.WorkItemExecution
1153429 dotnet/runtime System.IO.Tests.WorkItemExecution
1152834 dotnet/runtime System.IO.Tests.WorkItemExecution
1152248 dotnet/runtime System.IO.Tests.WorkItemExecution
1151853 dotnet/runtime System.Numerics.Tests.modpowTest.RegressionIssuePerformance2575 #119846
1151627 dotnet/runtime System.IO.Tests.WorkItemExecution
1151114 dotnet/runtime System.IO.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 16 48

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

Build Definition Test Pull Request
1151853 dotnet/runtime System.Numerics.Tests.modpowTest.RegressionIssuePerformance2575 #119846
1151627 dotnet/runtime System.IO.Tests.WorkItemExecution
1151114 dotnet/runtime System.IO.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 3 3

Report

Build Definition Test Pull Request
1167858 dotnet/runtime System.IO.Tests.WorkItemExecution
1167605 dotnet/runtime System.IO.Tests.WorkItemExecution #120462
1167270 dotnet/runtime System.IO.Tests.WorkItemExecution
1166867 dotnet/runtime System.IO.Tests.WorkItemExecution
1166378 dotnet/runtime System.IO.Tests.WorkItemExecution
1166120 dotnet/runtime System.IO.Tests.WorkItemExecution
1165989 dotnet/runtime System.IO.Tests.WorkItemExecution
1165833 dotnet/runtime System.IO.Tests.WorkItemExecution
1165507 dotnet/runtime System.IO.Tests.WorkItemExecution
1165234 dotnet/runtime System.IO.Tests.WorkItemExecution
1165079 dotnet/runtime System.IO.Tests.WorkItemExecution #120374
1164609 dotnet/runtime System.IO.Tests.WorkItemExecution
1164127 dotnet/runtime System.IO.Tests.WorkItemExecution
1163522 dotnet/runtime System.IO.Tests.WorkItemExecution
1163156 dotnet/runtime System.IO.Tests.WorkItemExecution
1162437 dotnet/runtime System.IO.Tests.WorkItemExecution
1162003 dotnet/runtime System.IO.Tests.WorkItemExecution
1161477 dotnet/runtime System.IO.Tests.WorkItemExecution
1161044 dotnet/runtime System.IO.Tests.WorkItemExecution
1160492 dotnet/runtime System.IO.Tests.WorkItemExecution
1160225 dotnet/runtime System.IO.Tests.WorkItemExecution
1160091 dotnet/runtime System.IO.Tests.WorkItemExecution
1159967 dotnet/runtime System.IO.Tests.WorkItemExecution
1159811 dotnet/runtime System.IO.Tests.WorkItemExecution
1159546 dotnet/runtime System.IO.Tests.WorkItemExecution
1159087 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1159003 dotnet/runtime System.IO.Tests.WorkItemExecution
1158922 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1158508 dotnet/runtime System.IO.Tests.WorkItemExecution
1158133 dotnet/runtime System.IO.Tests.WorkItemExecution #106880
1158053 dotnet/runtime System.IO.Tests.WorkItemExecution #119459
1157808 dotnet/runtime System.IO.Tests.WorkItemExecution
1157349 dotnet/runtime System.IO.Tests.WorkItemExecution
1156839 dotnet/runtime System.IO.Tests.WorkItemExecution
1156363 dotnet/runtime System.IO.Tests.WorkItemExecution
1155882 dotnet/runtime System.IO.Tests.WorkItemExecution
1155421 dotnet/runtime System.IO.Tests.WorkItemExecution
1154724 dotnet/runtime System.IO.Tests.WorkItemExecution
1154346 dotnet/runtime System.IO.Tests.WorkItemExecution
1154137 dotnet/runtime System.IO.Tests.WorkItemExecution
1154038 dotnet/runtime System.IO.Tests.WorkItemExecution
1153847 dotnet/runtime System.IO.Tests.WorkItemExecution
1153429 dotnet/runtime System.IO.Tests.WorkItemExecution
1152834 dotnet/runtime System.IO.Tests.WorkItemExecution
1152248 dotnet/runtime System.IO.Tests.WorkItemExecution
1151853 dotnet/runtime System.Numerics.Tests.modpowTest.RegressionIssuePerformance2575 #119846
1151627 dotnet/runtime System.IO.Tests.WorkItemExecution
1151114 dotnet/runtime System.IO.Tests.WorkItemExecution

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
3 16 48

Report

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 0

Activity

  1. added
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Sep 18, 2025
  2. added and removed
    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
    on Sep 19, 2025
  3. added this to the 11.0.0 milestone on Sep 19, 2025
  4. dotnet-policy-service commented on Sep 19, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-io
    See info in area-owners.md if you want to be subscribed.

  5. vitek-karas commented on Oct 1, 2025

    @vitek-karas
    MemberAuthor

    Likely would be "fixed" if we implemented dotnet/xharness#1473

  6. removed their assignment
    on Oct 1, 2025
  7. matouskozak commented on Oct 8, 2025

    @matouskozak
    Member

    I've updated the error messge to [FAIL] System.IO.Tests.MemoryStreamTests.MemoryStream_CapacityBoundaryChecks as 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)
    
  8. janvorli commented on Nov 26, 2025

    @janvorli
    Member

    I think runtime throws a wrong exception. It comes from this place in the AllocateSzArray:

    if ((SIZE_T)cElements > MaxArrayLength())
    ThrowOutOfMemoryDimensionsExceeded();

    I believe array allocation should throw ArgumentOutOfRangeException as the test checks when the requested size is larger than the maximum index. The OutOfMemoryException should be thrown only when the requested size is in range, but the allocation failed.

    @jkotas am I right?

  9. jkotas commented on Nov 26, 2025

    @jkotas
    Member

    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

  10. locked and limited conversation to collaborators on Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions