Repository navigation
Capture unit-test hang dumps and bound CI test steps - #41038
Conversation
Enable MTP HangDump for unit-test pipeline invocations, retain named-test diagnostics with existing result artifacts, and add a per-step timeout before the job-wide limit. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Expert Review — No more findings
Reviewed commit 7c68860.
Selected Tests🧪 Test selection — click to expand
🧪 UI tests — nothing to runℹ️ The AI found no changes relevant to UI tests, so no GPT-6.2 Sol: Unit-test hang diagnostics and deadlines leave PR UI tests unchanged. 🧪 Running — nothingNo UI tests run for this PR. 🧪 Device tests — nothing to runℹ️ The AI found no changes relevant to device tests, so no GPT-6.2 Sol: Unit-test CI changes leave Helix device test builds and execution unchanged. 🧪 Running — nothingNo device tests run for this PR. ⏭️ Skipped — what neither suite runsUI tests — 77 categories, 4 platforms Platforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and category is listed as a Device tests — 105 categories, 4 platforms Platforms not run: Android, iOS, MacCatalyst, Windows Each skipped platform and project is listed as a 🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)UI testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — Unit-test hang diagnostics and deadlines leave PR UI tests unchanged.
MAI Code 2 — Unit-test pipeline diagnostics and timeout changes; no UI or device tests are affected.
Device testsEach model chose independently; every test that runs was selected by at least one of them.
GPT-6.2 Sol — Unit-test CI changes leave Helix device test builds and execution unchanged.
MAI Code 2 — Unit-test infrastructure changes do not affect native device test behavior.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification. |
MAUI Autopilot — Ready for maintainer reviewResults
|
<!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `7eaf806f7513810dcbd94ca03a1500a5ee4302f4` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 9.5/10 | ↑ [PR CI 1706633](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1706633) completed with all 33 jobs green, including all four TestUtils runner and TRX validation pairs.<br>↑ The local suite also runs without the opt-in; device-host invocation, test selection and pipeline configuration are unchanged. | | Diagnosis confidence | 10/10 | ↑ The HangDump package was already restored, but the custom entry point did not register its provider; removing only the registration reproduces exit 5, and restoring it produces a valid TRX. | | Evidence fit | 10/10 | ↑ The local baseline matched all four Windows/macOS CI failures, and the same four configurations now execute tests and validate their TRX with the original HangDump options. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change <!-- Enter description of the fix in this section --> `TestUtils.UnitTests` exits before running any tests on Windows and macOS Debug/Release in [net11 maui-pr 1706373](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1706373), with an invalid-arguments handshake failure (exit 5). #41038 passes `--hangdump` and restores the HangDump package, but this project supplies its own MTP entry point, so referencing the package doesn't register its provider. Register HangDump in the custom host only when `TestUtils.UnitTests` builds with `EnableUnitTestHangDump=true`. Leave the diagnostic flags, ordinary test runs, and device test hosts unchanged. **Validation:** Ran on macOS arm64 with the repository .NET 11 SDK: ```sh ./.dotnet/dotnet test --project src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --configuration Debug --report-trx --hangdump --hangdump-timeout 10m --hangdump-type Mini -p:_SkipUpdateBuildNumber=true -p:EnableUnitTestHangDump=true --results-directory <results-dir> ``` | Run | Result | | --- | --- | | Unchanged net11 with the CI flags | Exit 5, handshake failure, no tests ran | | Unchanged net11 without the three HangDump flags, package still enabled | 61 passed; 1 Windows-only test skipped | | Fixed Debug with CI flags | 61 passed; 1 skipped; MTP TRX produced | | Only the registration removed | Exit 5, handshake failure, no tests ran | | Registration restored, Debug and Release with CI flags | Each: 61 passed; 1 skipped; MTP TRX produced | | Fixed Debug without the HangDump flags or opt-in | 61 passed; 1 skipped | [maui-pr 1706633](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1706633) completed successfully, with 33 succeeded timeline jobs. All four targeted runner/validator pairs succeeded. Raw log pairs: macOS Debug 259/260 and Release 240/241 (61 passed, 1 skipped each); Windows Debug 333/334 and Release 367/368 (62 passed each). ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> No separate issue. Fixes the `TestUtils.UnitTests` handshake regression in #41038. ### Let AI finish this PR - [ ] **Let the MAUI agent address review feedback and fix remaining issues on this PR.** Maintainers still decide whether it is merged. For PRs from forks, the agent opens a follow-up PR that keeps your commits. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… initializers (#41206) <!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `f55e53f8cb45bc70f5529273116a30be6308c945` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 9/10 | ↑ Fresh-process concurrency harness: fix 0/200 hangs, restored 0/30.<br>↑ Core.UnitTests Release 1138/1138 x3; Controls.Core.UnitTests 6908 passed, 0 failed.<br>↓ CI on this PR not yet observed. | | Diagnosis confidence | 9.5/10 | ↑ dotnet-stack of a hung process shows Label..cctor holding the helper lock waiting on VisualElement, while VisualElement..cctor -> Element..cctor waits on the helper lock.<br>↑ Baseline 94/100 hung, reverted 29/30 hung. | | Evidence fit | 8.5/10 | ↑ CI hangs show exactly the first-use Controls tests (Label, ContentView, Button, DatePicker, Grid, mapper tests) all blocked at startup.<br>↓ CI createdump failed, so no CI-side stack confirms the identical cycle. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change **Symptom:** `maui-pr` on `candidate/11.0.1xx-sr3` intermittently fails "macOS unit tests (Release)". In about half of the runs, `Core.UnitTests` stalls with 11 tests blocked from startup until the hangdump timeout (exit 7). Examples: builds 1706437, 1706493, 1707019, 1707055, 1707205 and PR build 1707259. These hangs show up as failures because of the hang-dump infra from #41038. **Root cause:** `RemappingHelper` held a single global lock while running each Controls remap. #40930 changed `static Label()` to remap through the helper. Label's remap calls `VisualElement.RemapIfNeeded()`, which requires VisualElement's type initializer. With concurrent first use: - Thread A: `Label..cctor` → takes the helper lock → waits for `VisualElement..cctor` - Thread B: `VisualElement..cctor` (static brush field) → `Element..cctor` → `Element.RemapIfNeeded` → waits for the helper lock Neither thread can proceed, and the runtime does not detect a cycle that mixes a monitor with type-init locks. The `dotnet-stack` capture of a hung repro process shows exactly these two frames. **Fix:** keep the run-once state in a short global lock, but run each remap under a **per-type** lock. Same-type callers still wait for completion. Reentrancy on the same thread still returns immediately. A remap that throws is still not retried. Remaps of different types no longer block each other, and the type dependency chain (Label → VisualElement → Element) is acyclic. `main` removed this helper in a larger lazy-remap redesign (#40725/#40728), which is not appropriate for this candidate. ### Validation A fresh-process harness against the built assemblies creates `Label`, `ContentView`, `Button`, `BoxView`, `Grid` and `DatePicker` on 6 barrier-synchronized threads, with an 8 s join: | Tree | Hung | |---|---| | Baseline e69e972 | 94/100 | | Fix | 0/200 | | Fix reverted | 29/30 | | Restored | 0/30 | - `dotnet test --project src/Core/tests/UnitTests/Core.UnitTests.csproj -c Release`: 1138/1138 passed, 3 runs. - `dotnet test --project src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -c Release`: 6908 passed, 0 failed (30 skipped). This includes `LabelMapperCustomizationTests` from #40930. ### Issues Fixed Fixes the intermittent macOS Release Core.UnitTests hang on `candidate/11.0.1xx-sr3`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…41224) <!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `946bedc34f141ef215926b962ba240a7bf31d75e` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 9.5/10 | ↑ Exact cherry-pick of net11 #41148, whose PR CI passed all four TestUtils runner/validator pairs.<br>↑ Local sr3 run with CI's exact flags produces a TRX (61 passed, 1 skipped, 0 failed).<br>↓ sr3 maui-pr CI on this head is still pending. | | Diagnosis confidence | 10/10 | ↑ Causal sequence on sr3 2253c0b: baseline exit 5, fix exit 0, fix reverted exit 5, restored exit 0. | | Evidence fit | 10/10 | ↑ Matches the sr3 maui-pr 1707534 failure (`--hangdump ... -p:EnableUnitTestHangDump=true` then "exit code: 5. The command-line arguments are invalid") on Windows and macOS. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change Cherry-pick (`-x`) of net11 #41148 onto `candidate/11.0.1xx-sr3`. `TestUtils.UnitTests` exits before running any tests in sr3 [maui-pr 1707534](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1707534) on Windows and macOS. MTP reports exit 5, "command-line arguments are invalid". The cause: #41038 passes `--hangdump` and restores the HangDump package, but this project supplies its own MTP entry point (`HeadlessTestRunner`). That entry point never registered the HangDump provider, so MTP rejected the flag. The fix registers `AddHangDumpProvider()` when `EnableUnitTestHangDump=true`, using the `ENABLE_UNIT_TEST_HANG_DUMP` define. ### Validation Ran locally on sr3 `2253c0bf`, with the same flags CI uses: `dotnet test --project src/TestUtils/tests/TestUtils.UnitTests/TestUtils.UnitTests.csproj --configuration Debug --report-trx --hangdump --hangdump-timeout 10m --hangdump-type Mini --results-directory <dir> -p:_SkipUpdateBuildNumber=true -p:EnableUnitTestHangDump=true` | State | Exit | TRX | |---|---|---| | Baseline (sr3) | 5 | none | | Fix | 0 | 62 total, 61 passed, 1 skipped (Windows-only) | | Fix reverted | 5 | none | | Restored | 0 | 62 total, 61 passed, 1 skipped (Windows-only) | ### Issues Fixed N/A. This is a candidate CI fix, a port of #41148. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
637ebab0d315691e81c07ecbc392ee81cf120a8b↑ macOS arm64/.NET 11 smoke test produced a mini dump and named-test log, then exited nonzero; normal execution passed.
↓ Full MAUI test matrix, Azure task timeout behavior and artifact upload remain unverified.
↓ This diagnoses the missing diagnostics, not the underlying intermittent Core test hang.
↓ The original intermittent stall was not reproduced locally.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewFor .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Release/macOS unit-test runs intermittently stop after starting Core.UnitTests and remain silent until the 240-minute job deadline. The current direct-MTP unit-test template, introduced by #40763, has neither a hang collector nor a per-invocation deadline. Consequently, the hang is unidentified and later suites never run.
Microsoft.Testing.Extensions.HangDump, pinned to the existing MTP version (2.5.1). The new MSBuild opt-in keeps ordinary builds and native device runners unchanged.--hangdump --hangdump-timeout 10m --hangdump-type Minifor both the shared project loop and Windows-only BlazorWebView unit tests. MTP captures a dump, records in-progress test names when the host can respond, and terminates the hung host. Mini dumps retain stacks while limiting artifact size.succeededOrFailed()execution andalways()validation/publication paths. Dumps and companion.logfiles are written beneath the existing per-project results directory, so the existingUnitTests-<job>-<configuration>-<attempt>artifact publishes them alongside TRX/binlogs.Scope: this identifies future hangs; it does not claim to fix or identify the original hanging Core test. No speculative animation-test changes are included.
Main also needs this change: the live
mainunit-test template matchednet11byte-for-byte when checked. This PR targets the explicitly assignednet11; forward-port the diagnostics tomainas well.Validation
pwsh -NoProfile -Command 'Invoke-Pester -Path ./eng/pipelines/ci.Tests.ps1 -Output Detailed -CI'— passed, 20/20.dotnet msbuild src/Core/tests/UnitTests/Core.UnitTests.csproj -nologo -p:EnableUnitTestHangDump=true -getItem:PackageReference— passed; exactly one HangDump reference at2.5.1. The same evaluation without the opt-in excludes HangDump.git diff --checkpassed.4.0.2/MTP2.5.1, .NET 11 Release/macOS arm64 smoke fixture (not committed):DOTNET_MODIFIABLE_ASSEMBLIES=debug dotnet test --project HangDumpSmoke.csproj --configuration Release --report-trx --hangdump --hangdump-timeout 10m --hangdump-type Mini --results-directory results/pass— passed, 1/1.HANGDUMP_SMOKE_HANG=1 DOTNET_MODIFIABLE_ASSEMBLIES=debug dotnet test --project HangDumpSmoke.csproj --configuration Release --no-build --report-trx --hangdump --hangdump-timeout 10s --hangdump-type Mini --results-directory results/hang— expected failure, exit 7; console and companion log namedHangTests.IdentifiesTheHangingTest; nonempty mini dump produced. Only the timeout was shortened to exercise the watchdog promptly.Issues Fixed
No linked issue. Addresses missing diagnostics and unbounded unit-test steps observed during nightly CI triage; the underlying hanging test remains unknown.
Let AI finish this PR