Skip to content

[rel/4.5] Coalesce HangDump activity signals (#12167) - #12231

Merged
Amaury Levé (Evangelink) merged 4 commits into
rel/4.5from
evangelink-hangdump-45-backport
Nov 6, 2026
Merged

Amaury Levé (Evangelink) merged 4 commits into
rel/4.5from
evangelink-hangdump-45-backport

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Backport #12167, Coalesce HangDump activity signals instead of one IPC round trip per test, to rel/4.5.

Preserve the upstream contract: result consumption only marks pending activity; the single-flight background loop sends at timeout/10, clamped to 10 ms–1 s; session finishing stops/awaits the loop before its final flush; cancellation, error reporting, idempotent/bounded disposal and deferred pipe disposal remain intact. Both processes use the same timeout + interval inactivity-timer formula, including timer-period splitting at the maximum supported timeout, so coalescing does not cause an early dump. Timeout parsing/defaults and the absolute CI deadline behavior are unchanged. No public API, CLI option or dependency changes.

Provenance and servicing adaptation

  • Source: merged main PR #12167, commit 165333f32123111b70b3ead7f53e40e431c02055.
  • Release base, refreshed before editing and again before commit: 72fd2b4b64ea00b275e0c18b1aeb36159348c1c7.
  • Backport head: e86e86244840fc7a72715e8177b216b1b4da7115.
  • The three production files, InternalAPI entries and two existing unit-test files are the exact upstream six-file subset. Upstream and backport stable patch IDs for that subset both equal 8260cd998f94be0fd7324fc0903d0a9b7bf45429.
  • The full cherry-pick cannot apply because main-only HangDumpActivityBehaviorTests.cs, HangDumpInProcessLifecycleTests.cs and Helpers/HangDumpInProcessProtocolFixture.cs do not exist on this release. Rather than import those broader suites and their fixture dependencies, retain the focused upstream regressions already supported by the release and add one self-contained packed-consumer fixture covering four coalescing cases.
  • No changes from Restore disabled MSTest adapter platform-services tests #12208 or Avoid thread-pool starvation in MTP recursive logging test #12221 are included. All work and comparison assets stay in this isolated worktree or task-owned app artifacts.

Exact changed paths (7 files; 739 insertions, 23 deletions):

src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpActivityIndicator.cs
src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpOptions.cs
src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs
src\Platform\Microsoft.Testing.Extensions.HangDump\InternalAPI\InternalAPI.Unshipped.txt
test\UnitTests\Microsoft.Testing.Extensions.UnitTests\HangDumpMutationTests.cs
test\UnitTests\Microsoft.Testing.Extensions.UnitTests\HangDumpTests.cs
test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\HangDumpActivityCoalescingTests.cs

Release validation

Windows x64, repository-pinned SDK 12.0.100-alpha.1.26480.103, bootstrapped through the build scripts. Runtime executions use bootstrapped .NET 8.0.33 and 10.0.14, .NET 9.0.22 for the unit suite, and the net462 legacy path. Packages were built before commit from the exact committed production changes; the final targeted runner includes the committed acceptance-test content.

Selection Executed Result
Full desktop release build + pack, including UAP package payload and NuGet content/metadata audit Full solution Passed; exit 0, 0 warnings/errors
FullyQualifiedName~HangDump, net8.0 164 164 passed, 0 failed/skipped; exit 0
FullyQualifiedName~HangDump, net9.0 164 164 passed, 0 failed/skipped; exit 0
FullyQualifiedName~HangDump, net462 155 155 passed, 0 failed/skipped; exit 0
Packed-host acceptance selection below 12 12 passed, 0 failed/skipped; exit 0
Same four coalescing cases after restoring the candidate package 4 4 passed, 0 failed/skipped; exit 0

The 12 packed-host cases are:

  • HangDumpActivityCoalescingTests.HangDump_BurstOfResults_CoalescesAcknowledgedActivityBeforeExit: net8.0 and net10.0, each with and without TRX. Every app completes 5,000 results, sends one activity signal, and receives one acknowledgement; the conservative allowed maximum is two. TRX-enabled cases also contain all 5,000 results.
  • HangDumpTests.HangDump_DefaultSetting_CreateDump: net8.0, net10.0, net462; real inactivity-triggered dump creation and non-graceful host exit.
  • HangDumpTests.HangDump_AbsoluteDeadline_CreateDump: net8.0, net10.0, net462; real deadline-triggered dump creation while the inactivity timeout is 30 minutes.
  • HangDumpTests.HangDump_WithDotnetTest_NoHangButOverallTimeGreaterThanTimeout_ShouldPass: succeeds without a dump even though the two active tests together exceed the configured inactivity timeout.
  • HangDumpPlusTrxTests.HangDumpPlusTrx_WhenTestHostHangs_RecoversCompletedResultsAndFailedResultSummary: real dump/kill path, recovered completed result, absent unfinished result and failed TRX summary.

Executed build commands (both final commands passed with exit 0 and zero warnings/errors):

& $env:ComSpec /d /c 'build.cmd -c Release -pack -msbuildEngine vs -bl -nodeReuse:$false'
& .\eng\build.ps1 -restore -build -c Release -msbuildEngine dotnet -projects 'test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj' -binaryLog -nodeReuse:$false -properties '/p:NetCurrent=net10.0'

The acceptance runner is built on the installed .NET 10 runtime because the default runner TFM is net11.0 while this release's global.json bootstraps 8/9/10 runtimes. This is a validation-only property override, not a repository/framework migration; the generated shipping apps still use the release matrix.

Executed direct-host selections are shown below with local reporting flags omitted. Each actual invocation also used --report-trx, a phase-specific TRX filename and a task-owned results directory. DOTNET_ROOT and PATH were set to the repo-local .dotnet; the generated assets' restore folders and executed DLL hashes were inspected to rule out stale/shared package consumption.

# Each passed, exit 0: 164, 164 and 155 cases respectively.
& .\artifacts\bin\Microsoft.Testing.Extensions.UnitTests\Release\net8.0\Microsoft.Testing.Extensions.UnitTests.exe --no-banner --progress off --filter 'FullyQualifiedName~HangDump'
& .\artifacts\bin\Microsoft.Testing.Extensions.UnitTests\Release\net9.0\Microsoft.Testing.Extensions.UnitTests.exe --no-banner --progress off --filter 'FullyQualifiedName~HangDump'
& .\artifacts\bin\Microsoft.Testing.Extensions.UnitTests\Release\net462\Microsoft.Testing.Extensions.UnitTests.exe --no-banner --progress off --filter 'FullyQualifiedName~HangDump'

# Passed, exit 0: 12 cases.
& .\artifacts\bin\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Release\net10.0\Microsoft.Testing.Platform.Acceptance.IntegrationTests.exe --no-banner --progress off --filter 'FullyQualifiedName~HangDumpActivityCoalescingTests|FullyQualifiedName~HangDump_DefaultSetting_CreateDump|FullyQualifiedName~HangDump_AbsoluteDeadline_CreateDump|FullyQualifiedName~HangDump_WithDotnetTest_NoHangButOverallTimeGreaterThanTimeout_ShouldPass|FullyQualifiedName~HangDumpPlusTrx_WhenTestHostHangs_RecoversCompletedResultsAndFailedResultSummary'

# Exact retained selection: baseline exit 2 with four assertion failures; restored candidate exit 0, four passed.
& .\artifacts\bin\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Release\net10.0\Microsoft.Testing.Platform.Acceptance.IntegrationTests.exe --no-banner --progress off --filter 'FullyQualifiedName~HangDumpActivityCoalescingTests'

An initial dotnet-engine pack with SkipUapTargetFramework=true failed the unchanged MSTest package-layout audit because UAP files were absent. This was resolved by the compatible installed desktop MSBuild 18.11 and a complete UAP-inclusive pack; no validation was disabled and no unrelated package metadata was changed. The failed net8.0 runner-build attempt exposed an existing net9+ Lock helper; the final net10.0 runner build succeeds without modifying it.

Genuine behavioral red/green and test value

Before changing source, build and preserve the exact release-baseline HangDump package using:

# Passed, exit 0; netstandard2.0/net8.0/net9.0 build and package metadata validation.
& $env:ComSpec /d /c 'build.cmd -c Release -pack -msbuildEngine dotnet -projects src\Platform\Microsoft.Testing.Extensions.HangDump\Microsoft.Testing.Extensions.HangDump.csproj -bl -nodeReuse:$false'

Keep the committed coalescing tests and app source unchanged; replace only the HangDump package in this worktree's shipping feed with that preserved baseline, run all four cases, then restore the exact candidate in finally and rerun. Other aligned MTP/TRX packages stay unchanged. Both sides compile and launch successfully and complete all 5,000 app results.

Retained row Baseline sent/acknowledged signals Candidate sent/acknowledged signals Actual test outcome
net8.0, HangDump only 5000 / 5000 1 / 1 Baseline IPC-rate assertion fails (limit 3); restored candidate passes (limit 2)
net8.0, HangDump + TRX 5000 / 5000 1 / 1 Baseline IPC-rate assertion fails (limit 3); restored candidate passes (limit 2)
net10.0, HangDump only 5000 / 5000 1 / 1 Baseline IPC-rate assertion fails (limit 3); restored candidate passes (limit 2)
net10.0, HangDump + TRX 5000 / 5000 1 / 1 Baseline IPC-rate assertion fails (limit 4); restored candidate passes (limit 2)

The red phase is four executed assertion failures, process exit 2, not a build, discovery, launch, skip or zero-test failure. Parsed TRX counters/identities reconcile for the 483 unit cases and each acceptance phase. Actual app DLL hashes match the corresponding package's net8.0/net9.0 payload; net10.0 consumes the net9.0 shipping assembly.

  • Baseline HangDump package SHA256: B61F274CEEA4363C1FAA8B4B02BE1E6B9C2E4C8F61AE8CC2A4FBEB61EC2AFE8B.
  • Candidate/restored HangDump package SHA256: 43C16B39E62BBE6B46A8F712F90C6083FDABB6E73735FBF902DAAE6D5E9C8EB8.

Upstream regression identities retained include ConsumeAsync_CoalescesActivityInsteadOfSendingAnIpcRequestPerResult, GetActivitySignalInterval_IsATenthOfTheTimeoutWithinBounds, InactivityTimer_NeverExpiresBeforeTheTimeoutSinceTheLastActivity, both Dispose*_WaitsForInFlightActivitySignalBeforeReturning paths, bounded/deferred/repeated disposal cases, OnTestSessionFinishingAsync_CanceledSessionWithPendingActivity_CompletesSoLaterHandlersRun, and maximum timer-period splitting. Their state, cancellation, gate and timer-bound assertions executed on release TFMs. The executed shipping red/green specifically proves the per-result IPC regression; no separate mutation kill rate is claimed for the other families.

Evidence limits and media

No Linux/macOS execution or live-CI success is claimed; those remain CI coverage. No wall-clock speedup benchmark is claimed: elapsed launch time only provides a conservative signal-count bound, not a performance threshold. Binary logs, package/binary snapshots and phase-specific TRX results are retained in task-owned app artifacts, not uploaded as public attachments.

No screenshots/video are included: this is an internal IPC/lifecycle/timer change, and the exact source patch plus executable shipping-host red/green evidence are more useful than visual media. This PR is not merged and auto-merge is not enabled.

Backport the exact production and focused unit regressions from main commit 165333f. Add a scoped packed-host regression for servicing instead of importing main-only fixture suites.

Backport-source: 165333f

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Nov 5, 2026

@github-actions github-actions Bot 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.

🧪 Test quality review — PR #12231

🧵 Parallel safety

STATUS: PARTIAL — the pre-step inputs (changed-file lists) were empty, so the parallel-safety specialist was not run. Not a clean result. New unit tests use Task.Delay/gates and private-field reflection per instance; no shared static state was spotted in a quick read.

Per-test grades

GradeTestMutationNotesHow to improve
C (70–79) new HangDumpActivityIndicatorMutationTests.
OnTestSessionFinishingAsync_
AfterDispose_
DoesNotTouchTheDisposedLoop
N/A No assertion; passes whenever nothing throws. Assert _activitySignalTask is still null after the call.
A/B (not individually graded) other new/modified tests in HangDumpMutationTests, HangDumpTests, HangDumpActivityCoalescingTests N/A Skimmed only: assertions are specific (exact intervals, deferred disposal, period splitting). —

This advisory review is heuristic and non-blocking. Re-run with /review-tests, or /parallel-audit for the specialist.

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 36.3 AIC · ⌖ 0.721 AIC · ⊞ 7.6K · ◷

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 5, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 5, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Nov 5, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Nov 5, 2026
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Final test-triage resolution — Azure Pipelines build 1666239

Result: actionable, deterministic test failure in this PR. Confidence is high that it is not a flake. No issue is created because this is a one-off on this PR and below the durable-issue thresholds.

Affected legs: Linux Release and Windows Release, Microsoft.Testing.Platform.Acceptance.IntegrationTests (net11.0 host).

Failing test: HangDumpActivityCoalescingTests.HangDump_BurstOfResults_CoalescesAcknowledgedActivityBeforeExit, in the net8.0: HangDump only and net8.0: HangDump with TRX variants.

Signature: System.InvalidOperationException: Expected build output folder for metadata mode 'Reflection' was not found: '<testsuite>/HangDumpActivityCoalescing/bin/Release/net8.0'. Ensure the asset fixture builds the 'Reflection' variant (see TestAssetFixtureBase.SourceGenMetadataModes).

  • The failure is identical on Linux and Windows.
  • Both attempts failed on both OSes (attempt 1 and attempt 2 in the JUnit report).
  • No attempt passed, so this is not flaky.
  • The stable message points to a test or asset-fixture setup problem. The test expects a Reflection-mode build output that the HangDumpActivityCoalescing asset fixture doesn't produce.
  • This PR is a rel/4.5 backport of Coalesce HangDump activity signals instead of one IPC round trip per test #12167. The test infrastructure on this branch probably doesn't match the one the original change targeted.
  • history.json is complete and has no earlier occurrence of this test failing.

Next step: make the new test's asset fixture build or declare the Reflection metadata mode, or adapt the test to the SourceGenMetadataModes available on rel/4.5. Then re-run the acceptance tests.

Not product failures:

  • Failures in WinUIMtpPackagedApp...RetryFailsFirstAttempt, PackagedWinUI...RetryTestMethod_PassesOnSecondAppContainerHost and NativeTests.Outcome come from the Windows App Model diagnostics artifacts. Their messages say the failures are deliberate probes of host failure and retry behavior ("expected host failure", "deliberately fails the first retry attempt").
  • The unit-test memory warning was not a failure.
  • Evidence was complete (evidenceIncomplete=false), and there are no crash or dump diagnostics. Slow-test candidates showed no regressions.

🤖 Automated content by GitHub Copilot. Generated by the Pipeline Test Triage workflow. · copilot · auto · ~31 AIC · ⌖ ~1 AIC · ⊞ 10.1K

@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/approved Proposal approved; ready for implementation. labels Nov 6, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 6, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 6, 2026

@github-actions github-actions Bot 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.

🧪 Test quality review — PR #12231

🧵 Parallel safety

STATUS: PARTIAL. The pre-step input files were empty, so I did not run the parallel-safety specialist and this PR has no parallel-safety coverage. Notes:

  • HangDumpActivityCoalescingTests builds a unique Guid result directory but shares one generated asset, which is fine.
  • The unit tests use per-test instances.

Per-test grades

GradeTestMutationNotesHow to improve
C (70–79) new HangDumpActivityIndicatorMutationTests.
OnTestSessionFinishingAsync_
AfterDispose_
DoesNotTouchTheDisposedLoop
N/A No assertion; it only checks that no exception is thrown. Assert that `_activitySignalTask` is null after the call.
A/B (80–100) new HangDump_BurstOfResults_
CoalescesAcknowledgedActivityBeforeExit
, the other new Dispose/GetActivitySignalInterval/InactivityTimer tests in HangDumpMutationTests, and GetTimerPeriod_* and ActivityTimer_* in HangDumpTests
N/A I only did a quick pass on these tests and did not grade each one individually. —

This advisory review is heuristic and non-blocking. Re-run with /review-tests or /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 32.7 AIC · ⌖ 0.72 AIC · ⊞ 7.6K · ◷

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 6, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 6, 2026
Derive the plain/TRX rows from the same TargetFrameworks.Net list used by the generated fixture. FastAcceptanceTest intentionally omits net8.0, so hard-coded rows requested outputs CI never built. Normal mode retains all four rows and all shipping-host assertions are unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/approved Proposal approved; ready for implementation. labels Nov 6, 2026
@Evangelink

Copy link
Copy Markdown
Member Author

Expected build output folder for metadata mode 'Reflection' was not found: .../HangDumpActivityCoalescing/bin/Release/net8.0.

Fixed in 7805195. The cause was the CI FastAcceptanceTest matrix omitting net8.0 from the generated fixture while the test rows still hard-coded it, not missing Reflection registration. Both now use TargetFrameworks.Net; no signal-rate, acknowledgement, result-count or TRX assertion was removed or weakened.

Reproduced the exact fast-mode failure before editing (2 passed, 2 failed). After the fix, the packed-host selection passes in fast mode (2/2) and normal mode (4/4, retaining .NET 8), with no skips and one acknowledged activity signal per 5,000 results. The refreshed HangDump pack and both targeted runner builds also pass. Live CI on the pushed head is still pending.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 6, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 6, 2026

@github-actions github-actions Bot 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.

🧪 Test quality review — PR #12231

🧵 Parallel safety

PARALLEL-SAFETY RESULT
STATUS: PARTIAL
NOTES: The parallel-safety specialist was not run to completion; coverage is incomplete and this must not be read as CLEAN.
END PARALLEL-SAFETY RESULT

A light manual read of HangDumpMutationTests.cs found no obvious shared static state. The tests build their own indicator instances and use gated TaskCompletionSources. Please run /parallel-audit for a complete assembly-scoped result.

Per-test grades

Coverage is limited: this is a reduced-depth review of HangDumpMutationTests.cs. Per-test letter grades and inline suggestions were not produced, so no test is reported as A.

Observations, not grades:

  • Several tests read and write private fields by reflection (_exitSignalActivityIndicatorAsync, _activitySignalPending, _activitySignalTask, _namedPipeClient._disposed). That couples them to implementation names, so a rename breaks them silently or loudly. Prefer an internal seam or InternalsVisibleTo member where practical.
  • AssertDisposalWaitsForLoopAsync asserts "not completed" after a fixed Task.Delay(100). This can only produce false passes, never false failures, but it is a weak negative check. A deterministic rendezvous would be stronger.
  • ConsumeAsync_TracksOnlyRunningAttemptsAndEmitsTraceDiagnostics covers several transitions in one method. Splitting it would make failures easier to diagnose.
  • OnTestSessionFinishingAsync_AfterDispose_DoesNotTouchTheDisposedLoop has no explicit assertion. It only checks that no exception is thrown.

This advisory review is heuristic and non-blocking.

Re-run the combined review with /review-tests, or only the parallel-safety specialist with /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Test Quality Review on PR (on open / sync) workflow. · copilot · auto · 27 AIC · ⌖ 0.714 AIC · ⊞ 7.6K · ◷

@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 6, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 6, 2026
Make the post-finishing loop-state invariant explicit in the focused lifecycle regression, retaining its original no-throw check. Addresses review comment 4483349478.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the state/needs-review Awaiting review from the team. label Nov 6, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. state/approved Proposal approved; ready for implementation. labels Nov 6, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit e8db9f8 into rel/4.5 Nov 6, 2026
29 of 30 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the evangelink-hangdump-45-backport branch November 6, 2026 09:58
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants