Repository navigation
[ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash #130133
Description
Activity
- addedblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'Known Build ErrorUse this to report build issues in the .NET Helix tabUse this to report build issues in the .NET Helix tab
on Jul 2, 2026 - addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jul 2, 2026 - changed the title
[-][ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash (MSB4217/MSB4027 MetadataLoadContext disposed)[/-][+][ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash[/+]on Jul 2, 2026 Have we ever seen another instance of this failure? It is a crash in the task host that doesn't have an obvious cause, we can harden the exception handling and possibly diagnose it better but I have not seen any other instances.
- removedblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'untriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Jul 2, 2026 dotnet-policy-service commented
on Jul 10, 2026 ContributorMore actionsTagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.github-actions commented
on Jul 23, 2026 on Jul 23, 2026 – with GitHub ActionsContributorMore actionsWorkflow artifact: ci-fix
Artifact kind: handoff
Linked KBE: #130133Root-cause analysis (read-only hand-off)
Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittablefails because theManagedToNativeGeneratorMSBuild task host crashes instead of emitting the expected pinvoke-blittable diagnostic:WasmApp.Common.targets(787,5): error MSB4217: Task host node exited prematurely. WasmApp.Common.targets(796,7): error MSB4027: The "ManagedToNativeGenerator" task generated invalid items from the "FileWrites" output parameter. This object is no longer valid because the MetadataLoadContext that created it has been disposed.Because the expected diagnostic never prints, the downstream
Assert.Matchesfails. TheMSB4027 MetadataLoadContext ... has been disposedis the real root cause: the task returnsFileWritesitems whose backingMetadataLoadContexthas already been disposed when MSBuild marshals them across the task-host boundary.Why this is a hand-off (no safe automated diff)
- This is a lifetime bug in the
ManagedToNativeGeneratortask (likely disposing theMetadataLoadContextbefore/whileFileWritesoutputs are still referenced). A correct fix requires understanding the task's disposal/output ordering insrc/tasks/and validating a full WASM build — it exceeds the small, single-file validated-fix bounds, and the intermittent (~0.24%) task-host crash is not reliably reproducible in this read-only environment. - Not related to the first-observed PR [mobile] Enable NativeAOT library tests on Apple mobile platforms #125437 (Apple-mobile NativeAOT tests); the crash is in shared WASM build tooling.
I could not produce a confidently-correct, build-validated diff for the task-host lifetime issue, so I'm handing off to the owners rather than guessing at disposal ordering.
Suggested reviewers / area contacts
area-Build-mono:@lewing,@akoeplinger
Note
This root-cause hand-off was generated by an AI/Copilot agent (
ci-failure-fix). No validated code change was produced because a correct fix to theManagedToNativeGeneratortask-host lifetime bug requires a full WASM build to validate, which is out of scope for this read-only run. Please verify before acting.Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpg
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:network: allowed: - defaults - "awmgmcpg"
See Network Configuration for more information.
Generated by CI Outer-Loop Failure Fixer · 520.3 AIC · ⌖ 18.1 AIC · ⊞ 17.1K · ◷
- This is a lifetime bug in the
Build Information
Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1491378
Build error leg or test failing:
runtime / Build / browser-wasm linux Release— Helix work itemWBT-NoWebcil-MONO-ST-Wasm.Build.Tests.PInvokeTableGeneratorTests(queueUbuntu.2604.Amd64.Open)Failing test (symptom):
Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittable(config: Release, aot: False)Pull request (first observed): #125437
Error Message
{ "ErrorMessage": "error MSB4027: The \"ManagedToNativeGenerator\" task generated invalid items from the \"FileWrites\" output parameter. This object is no longer valid because the MetadataLoadContext that created it has been disposed.", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": false }Failure details:
The WASM
not_blittablebuild insidePInvokeTableGeneratorTestsis expected to fail with the diagnosticerror : Parameter types of pinvoke callback method '...' needs to be blittable. Instead, theManagedToNativeGeneratorMSBuild task host crashed and the build failed early with:Because the expected pinvoke-blittable diagnostic never printed, the test's
Assert.Matchesfailed downstream:The
Assert.Matches Pattern not foundmessage and theWorkItemExecution ... BadExitentry that BuildAnalysis lists separately are both symptoms of the same root cause: the
ManagedToNativeGeneratortask-host crash (
MSB4217+MSB4027 MetadataLoadContext ... has been disposed). Tracking the rootcause is more reusable than the downstream assertion text.
This is an infrastructure/flaky MSBuild task-host crash (Build Analysis reports a ~0.24% failure rate) and
is unrelated to the change in PR #125437 (Apple-mobile NativeAOT library tests).
Affected legs:
runtime / Build / browser-wasm linux Release→ HelixWBT-NoWebcil-MONO-ST-Wasm.Build.Tests.PInvokeTableGeneratorTestsConsole Log:
WBT-NoWebcil-MONO-ST-Wasm.Build.Tests.PInvokeTableGeneratorTestsFirst build in window:
Recommended action:
File as a Known Build Error so Build Analysis correlates future occurrences of the
ManagedToNativeGeneratortask-host crash. Consider setting
BuildRetry: trueif this flake recurs frequently, since the crash istransient and a rebuild typically produces the expected diagnostic.
Note
This issue was drafted with GitHub Copilot assistance and reviewed by the submitting developer.
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1491378
Error message validated:
[error MSB4027: The "ManagedToNativeGenerator" task generated invalid items from the "FileWrites" output parameter. This object is no longer valid because the MetadataLoadContext that created it has been disposed.]Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 7/2/2026 4:17:46 PM UTC
Report
Summary