Prevent Test Hangs Caused By Concurrent Trace Listener Mutation - #2465
Open
Brian Robbins (brianrob) wants to merge 5 commits into
Open
Prevent Test Hangs Caused By Concurrent Trace Listener Mutation#2465Brian Robbins (brianrob) wants to merge 5 commits into
Brian Robbins (brianrob) wants to merge 5 commits into
Conversation
Run only the tests that mutate the process-wide Trace.Listeners collection exclusively, while preserving the assertion tests that validate ThrowingTraceListener configuration. Add a VSTest safety timeout for future hangs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Brian Robbins (brianrob)
force-pushed
the
brianrob/ci-test-hang
branch
from
September 3, 2026 17:02
c7b0d9d to
f16ab9c
Compare
Stop tests from mutating the process-wide trace listener collection, validate the configured listener before intentional assertions, and disable assertion UI in test configurations. Serialize TraceEvent tests to avoid the listener initialization race observed under the full workload. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document why modern .NET skips listener configuration checks and why .NET Framework validation does not repair listener state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Describe how assertion failures throw on .NET Framework and modern .NET, and explain why listener validation must not repair process-wide state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Eagerly load .NET Framework trace listener configuration from a module initializer before xUnit starts test methods in parallel. Remove assembly-wide TraceEvent test serialization while preserving validation-only listener checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent assertion dialogs from blocking test runs while preserving parallel execution.
Trace.Listenerscollection.TraceEventTestsmodule initializer before xUnit starts test methods in parallel.app.configfiles while retainingThrowingTraceListener.FastSerialization.Tests.Root cause
Trace.Listenersis process-wide state and its configuration is loaded lazily. The ELF mismatch tests previously cleared and restored that collection while other tests could use it, allowing assertion tests to run withDefaultTraceListenerand open an interactive assertion dialog.Removing the explicit listener mutation fixed that race, but the full parallel
TraceEventTestsworkload also reproduced concurrent first access to the lazily initialized listener configuration. The module initializer now forces that configuration to finish loading on one thread before any test method executes. Test parallelization remains enabled.On .NET Framework,
AssertValid()verifies thatDefaultTraceListeneris absent andThrowingTraceListenerwas registered by the test assembly'sapp.config. It only inspects the collection because repairing process-wide listener state could introduce another race. Modern .NET ignores thisapp.configdiagnostics section, but its built-in assertion behavior already throws; the assertion tests verify that behavior directly.Validation
TraceEvent.Testsbuilds successfully fornet462andnet8.0.TraceEvent.Testsparallelization enabled.2acb78c01d6d3331e6b091740827b80c15dfd1e9completed both thePerfView_DebugandPerfView_Releasetest tasks without a hang. Nineteen builds passed; build 1583681 completed normally but had two unrelated transientTdhEnumerateProviderstest failures.CI build IDs: 1583568, 1583609, 1583612, 1583613, 1583614, 1583615, 1583652, 1583653, 1583654, 1583655, 1583656, 1583678, 1583679, 1583680, 1583681, 1583682, 1583734, 1583735, 1583736, 1583737.