Skip to content

Conversation

@VSadov
Copy link
Member

@VSadov VSadov commented Nov 4, 2025

Test-only fix.

Fixes: #119187

The testcase creates and joins threads in a loop while another thread calls GetTotalAllocatedBytes and checks various invariants: if the result is not negative, grows over time, ...
This is not a stress test. The purpose is just to demonstrate that GetTotalAllocatedBytes works in the presence of threads starting and exiting. It does not need to run for very long.

Creating/joining threads nonstop appear to cause issues on arm32. Sometimes we see OOMs.
In particular there is a concern that the thread that creates threads + the actual threads may starve the main thread, thus arbitrarily prolonging the scenario.

Thie fix tries to limit the total number of threads that the test creates, making its completion more deterministic.

@VSadov VSadov added test-enhancement Improvements of test source code area-GC-coreclr labels Nov 4, 2025
@dotnet-policy-service
Copy link
Contributor

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

@VSadov
Copy link
Member Author

VSadov commented Nov 6, 2025

I've rebased/rerun the CI on this PR several times and did not see the issue reproducing. I think this is a sufficient fix for the test issue.

@VSadov VSadov marked this pull request as ready for review November 6, 2025 22:21
Copilot AI review requested due to automatic review settings November 6, 2025 22:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the reliability and performance of the TestAnotherThread test method in the GC.GetTotalAllocatedBytes test suite.

  • Adds an upper bound to the background task's loop to prevent potential infinite loops
  • Reduces main thread iterations from 1000 to 100 for faster test execution while maintaining adequate coverage
  • Maintains early termination capability when the test completes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-GC-coreclr test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NativeAOT] Test_GetTotalAllocatedBytes test fails with OutOfMemoryException

1 participant