Repository navigation
[ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash #130133
Description
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 item WBT-NoWebcil-MONO-ST-Wasm.Build.Tests.PInvokeTableGeneratorTests (queue Ubuntu.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_blittable build inside PInvokeTableGeneratorTests is expected to fail with the diagnostic
error : Parameter types of pinvoke callback method '...' needs to be blittable. Instead, the
ManagedToNativeGenerator MSBuild task host crashed and the build failed early with:
WasmApp.Common.targets(787,5): error MSB4217: Task host node exited prematurely. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt.
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 pinvoke-blittable diagnostic never printed, the test's Assert.Matches failed downstream:
Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittable(config: Release, aot: False) [FAIL]
Assert.Matches() Failure: Pattern not found in value
Regex: "error.*Parameter.*types.*pinvoke.*.*blittable"
Value: "[] Determining projects to restore...\n[] Rest"...
/_/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs(32,0)
The Assert.Matches Pattern not found message and the WorkItemExecution ... BadExit entry that Build
Analysis lists separately are both symptoms of the same root cause: the ManagedToNativeGenerator
task-host crash (MSB4217 + MSB4027 MetadataLoadContext ... has been disposed). Tracking the root
cause 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.PInvokeTableGeneratorTests
Console Log:
- console.352ebce7.log (runId 41125472), work item
WBT-NoWebcil-MONO-ST-Wasm.Build.Tests.PInvokeTableGeneratorTests
First build in window:
- Build 1491378 (PR [mobile] Enable NativeAOT library tests on Apple mobile platforms #125437, head SHA e34e28f)
Recommended action:
File as a Known Build Error so Build Analysis correlates future occurrences of the ManagedToNativeGenerator
task-host crash. Consider setting BuildRetry: true if this flake recurs frequently, since the crash is
transient 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
| 24-Hour Hit Count | 7-Day Hit Count | 1-Month Count |
|---|---|---|
| 0 | 0 | 0 |
Activity
[-][ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash (MSB4217/MSB4027 MetadataLoadContext disposed)[/-][+][ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash[/+]lewing commentedon 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.
dotnet-policy-service commentedon Jul 10, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
github-actions commentedon Jul 23, 2026
Workflow artifact: ci-fix
Artifact kind: handoff
Linked KBE: #130133
Root-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: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)
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.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,@akoeplingerNote
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:
awmgmcpgSee Network Configuration for more information.
x-itm commentedon Sep 16, 2026
zorathvael commentedon Oct 8, 2026