Skip to content

[ci-scan] Wasm.Build.Tests ManagedToNativeGenerator task host node crash #130133

Description

@kotlarmilos

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 → 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:

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

  1. added
    blocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
    Known Build ErrorUse this to report build issues in the .NET Helix tab
    on Jul 2, 2026
  2. 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
  3. lewing commented on Jul 2, 2026

    @lewing
    Member

    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.

  4. removed
    blocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
    untriagedNew issue has not been triaged by the area owner
    on Jul 2, 2026
  5. dotnet-policy-service commented on Jul 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  6. added this to the 12.0.0 milestone on Jul 14, 2026
  7. github-actions commented on Jul 23, 2026

    @github-actions
    Contributor

    Workflow artifact: ci-fix
    Artifact kind: handoff
    Linked KBE: #130133

    Root-cause analysis (read-only hand-off)

    Wasm.Build.Tests.PInvokeTableGeneratorTests.UnmanagedStructAndMethodIn_SameAssembly_WithoutDisableRuntimeMarshallingAttribute_NotConsideredBlittable fails because the ManagedToNativeGenerator MSBuild 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.Matches fails. The MSB4027 MetadataLoadContext ... has been disposed is the real root cause: the task returns FileWrites items whose backing MetadataLoadContext has 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 ManagedToNativeGenerator task (likely disposing the MetadataLoadContext before/while FileWrites outputs are still referenced). A correct fix requires understanding the task's disposal/output ordering in src/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 the ManagedToNativeGenerator task-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.allowed list 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 · ◷

  8. x-itm commented on Sep 16, 2026

    @x-itm
  9. zorathvael commented on Oct 8, 2026

    @zorathvael
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions