Skip to content

Re-enable the ArrayPool PollingEventFires test#131326

Open
tannergooding wants to merge 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-reenable-arraypool-pollingeventfires
Open

Re-enable the ArrayPool PollingEventFires test#131326
tannergooding wants to merge 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-reenable-arraypool-pollingeventfires

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Fixes #44037.

System.Buffers.ArrayPool.Tests.CollectionTests.PollingEventFires was disabled in 2020 via [ActiveIssue]. The original failure was a remote-process hang (Half-way through waiting for remote process. Timed out ... after 60000ms, child process idle at 0.13s CPU) against the old ArrayPool implementation, which has since been fully rewritten (SharedArrayPool<T>). The stale ActiveIssue was never revisited.


The BufferTrimPoll event is emitted from SharedArrayPool<T>.Trim(), which only runs inside a Gen2GcCallback finalizer. A single GC.Collect(2) + GC.WaitForPendingFinalizers() isn't guaranteed to promote-then-collect that freshly-registered callback object and run its finalizer, so the positive assertion could race. Harden the second poll check to retry a bounded number of times until the event fires.

Validated locally by running the test 30x under the current implementation with no hangs or failures.

Note

This PR was authored by Copilot (GitHub Copilot CLI) on behalf of @tannergooding.

The original failure (dotnet#44037) was a remote-process hang against the old
ArrayPool implementation, which has since been rewritten. Harden the poll
check against the Gen2GcCallback finalizer timing -- a single gen2 collection
isn't guaranteed to run the callback that emits the poll event -- by retrying
a bounded number of times.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 re-enables the System.Buffers.ArrayPool polling/trim EventSource test by removing the stale [ActiveIssue] skip and making the test’s “event eventually fires” assertion more resilient to GC/finalizer timing.

Changes:

  • Removed [ActiveIssue("https://github.com/dotnet/runtime/issues/44037")] from PollingEventFires.
  • Hardened the second poll check by retrying GC.Collect(2) + GC.WaitForPendingFinalizers() up to a bounded number of times until the BufferTrimPoll event is observed.
Show a summary per file
File Description
src/libraries/System.Runtime/tests/System.Buffers.Tests/ArrayPool/CollectionTests.cs Re-enables PollingEventFires and adds a bounded retry loop to reduce GC/finalizer timing flakiness.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

The listener callback runs on the finalizer thread, so read/write the flag
with Volatile to avoid a visibility race with the retry loop.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 24, 2026 16:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Buffers.ArrayPool.Tests.CollectionTests.PollingEventFires failing in CI

2 participants