[ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
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): https://github.com/dotnet/runtime/pull/125437
## Error Message
```json
{
"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:
```text
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:
```text
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` → Helix `WBT-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 #125437, head SHA e34e28fd9f0bcaedd30b435725cd84ada56c941c)
**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: :mag_right:** 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:** :white_check_mark: Known issue matched with the provided build.
**Validation performed at:** 7/2/2026 4:17:46 PM UTC
### Report
|Build|Repository|Test|Pull Request|
|---|---|---|---|
|[1588168](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1588168)|dotnet/runtime|[Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittable(config: Release, aot: False)](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1588168&view=ms.vss-test-web.build-test-results-tab&runId=43834328&resultId=100143)|dotnet/runtime#133461|
|[1586814](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1586814)|dotnet/runtime|[Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittable(config: Release, aot: False)](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1586814&view=ms.vss-test-web.build-test-results-tab&runId=43791676&resultId=100143)||
#### Summary
|24-Hour Hit Count|7-Day Hit Count|1-Month Count|
|---|---|---|
|0|2|2|
Contributor guide
Research direction
Start with Wasm.Build.Tests/PInvokeTableGeneratorTests.cs and the failing test from build 1491378, then review the reported MSB4217 and MSB4027 task-host errors. Check how Known Build Errors are filed and validated; done means future occurrences of the ManagedToNativeGenerator crash are correlated, with BuildRetry considered if the transient failure recurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, wasm
- Domain
- build-system, ci-cd, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100