Skip to content

[Operational Issue]: crossgen2 fails to start with Text file busy on Azure Linux cross-build legs #8079

Open
NuGet/NuGet.Client
#7643

Description

@mmitche

Error

Azure Linux cross-build legs intermittently fail while building Roslyn because crossgen2 cannot be started:

error MSB6003: The specified task executable ".../microsoft.netcore.app.crossgen2.linux-x64/9.0.18/tools/crossgen2" could not be run.
System.ComponentModel.Win32Exception (26): Text file busy

This occurred in 6 shipping builds / 7 build legs during the last 14 days across release/10.0.1xx and internal/release/10.0.1xx.

Links

Root Cause

Unknown. The failure indicates an executable file-lock/race while launching the restored crossgen2 tool.

Blocking

  • This issue is blocking

Affected Releases

  • .NET 10
  • .NET 10 (SDK band build)
  • .NET 11

Activity

  1. mmitche commented on Aug 4, 2026

    @mmitche
    MemberAuthor

    New matching occurrences:

    Both match the tracked crossgen2 executable file-lock/race signature.

  2. akoeplinger commented on Aug 18, 2026

    @akoeplinger
    Member

    The build from main you mentioned (https://dev.azure.com/dnceng/internal/_build/results?buildId=3038492) doesn't show this issue from what I can see.

    According to my Kusto queries this happened exclusively on release/10.0.1xx or internal/release/10.0.1xx in the last 90 days

  3. akoeplinger commented on Aug 18, 2026

    @akoeplinger
    Member

    one possibility is that this is fixed in later versions of crossgen2 but we're still using version 9.0.18 in the roslyn build in 10.0.1xx for some reason

  4. akoeplinger commented on Aug 20, 2026

    @akoeplinger
    Member

    Investigation findings

    I inspected Roslyn binlogs from these occurrences:

    Build Leg Crossgen2
    3029918 Alpine ARM 9.0.18
    3034460 x64 and Alpine x64 9.0.18
    3035669 Alpine x64 9.0.18
    3045650 ARM64 and PGO ARM64 9.0.18
    3052625 Alpine ARM64 9.0.19

    The failure is therefore not specific to Crossgen2 9.0.18, one target architecture, Alpine, or PGO.

    In the analyzed failures, Crossgen2 never starts. The SDK’s RunReadyToRunCompiler task calls Process.Start, which immediately fails with Linux error 26, ETXTBSY:

    System.ComponentModel.Win32Exception (26):
    An error occurred trying to start process '.../tools/crossgen2'.
    Text file busy
    

    Most binlogs contain 89 failed starts from _CreateR2RImages. One contains 86 instances through the base ToolTask stack and another three through the RunReadyToRunCompiler override, still totaling 89. This indicates that a writable handle remains open for the duration of the R2R target, rather than this being a single transient launch collision.

    Common restore behavior

    Every sampled failing binlog has the same Language Server packaging sequence:

    1. PackAllRids.targets invokes a nested Restore with runtime-pack downloads enabled.

    2. That restore installs Microsoft.NETCore.App.Crossgen2.linux-x64 into Roslyn’s private package directory.

    3. Several other requests for the same package wait for the package lock and then report:

      Lock not required - Package already installed ...
      
    4. After restore returns, PackAllRids.targets invokes RID-specific Pack builds using BuildInParallel="true".

    5. The subsequent R2R operations cannot execute the newly installed Crossgen2 file.

    For example, the older failures install both Crossgen2 8.0.29 and 9.0.18 during this restore. Build 3052625 installs 8.0.30 and 9.0.19.

    A successful control build, 3050631, has the same restore/install sequence and completes successfully. Thus, installing Crossgen2 immediately before Pack creates the exposure window, but another timing-dependent event is required to trigger the failure.

    Suspected descriptor-inheritance mechanism

    NuGet’s Unix extraction implementation creates package files using libc creat():

    [DllImport("libc", EntryPoint = "creat")]
    private static extern int PosixCreate(...);

    creat() does not atomically set O_CLOEXEC. NuGet wraps the resulting descriptor in a SafeFileHandle and FileStream, but neither adds FD_CLOEXEC.

    On Linux, package extraction defaults to the stream-copy path rather than mmap. Crossgen2 9.0.19 is the first large payload in its package and is approximately 12.4 MB, so NuGet holds a writable descriptor to the executable during that copy.

    The proposed sequence is:

    1. NuGet opens tools/crossgen2 for writing using creat().
    2. While the copy is active, the same multi-node MSBuild process starts another worker or tool process.
    3. The child inherits the writable descriptor.
    4. Because the descriptor lacks FD_CLOEXEC, it survives the child’s execve.
    5. NuGet finishes extraction and closes its own descriptor.
    6. The child continues holding the writable descriptor.
    7. Subsequent attempts to execute Crossgen2 fail with ETXTBSY until that child exits.

    This is consistent with the general failure mode described in dotnet/runtime#58964.

    NuGet’s package locking does not prevent this. The .nupkg.metadata marker is written only after extraction is complete, so the later “Package already installed” messages establish that NuGet itself completed the installation. They do not establish that no child inherited one of the extraction descriptors.

    Why this appears limited to 10.0.1xx

    The issue has only been observed on release/10.0.1xx and internal/release/10.0.1xx. It has not appeared on 10.0.4xx, despite 1xx and 4xx using the same .NET 10 runtime implementation.

    The relevant branch difference is Roslyn’s packaging graph:

    • 10.0.1xx retains PackAllRids.targets.
    • It explicitly restores R2R packs and then invokes RID-specific packs in parallel.
    • 10.0.4xx removed this target as part of the newer Language Server packaging design in January 2026.
    • Both branches still contain NuGet’s creat() implementation, so the NuGet defect alone does not explain the branch restriction. The 1xx packaging graph supplies the timing and restore-to-R2R handoff needed to expose it.

    The first observed failure followed the 10.0.110 bootstrap SDK update around July 14–15. No direct semantic change to NuGet extraction, Unix process creation, or the Roslyn R2R code was found in that update. It likely changed scheduling or timing enough to expose a longstanding race.

    Potential mitigations

    The most targeted Roslyn-only workaround would be:

    1. After ResolveReadyToRunCompilers, copy the complete Crossgen2 tools directory to a RID/version-specific intermediate directory.
    2. Replace @(Crossgen2Tool) with an item pointing to the copied executable while preserving its metadata.
    3. Ensure the copy creates new files rather than hardlinks.

    ETXTBSY is inode-specific, so a writable descriptor inherited for the package-cache executable would not affect the copied executable.

    Another option is to perform the special restore in an isolated dotnet msbuild process using /m:1 /nr:false, wait for that process to exit, and then start the Pack builds.

    The underlying fix should be in NuGet: create extracted Unix files atomically with O_CLOEXEC. Setting FD_CLOEXEC afterward with fcntl() would leave a smaller fork race between open and fcntl.

    Analysis prepared with GitHub Copilot. Historical CI investigation used known-issue-history.

  5. JulieLeeMSFT commented on Sep 16, 2026

    @JulieLeeMSFT
    Member
  6. mmitche commented on Sep 16, 2026

    @mmitche
    MemberAuthor

    Yep, should reopen it. The fix was not applied.

  7. akoeplinger commented on Sep 16, 2026

    @akoeplinger
    Member

    The fix was merged to nuget-client dev branch in NuGet/NuGet.Client#7643, but not yet into a branch that is used in 10.0.1xx.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions