Skip to content

Isolate multithreaded build test from compiler-server mutex race - #56239

Open
JeremyKuhne with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-multithreaded-argument
Open

JeremyKuhne with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-flaky-test-multithreaded-argument

Conversation

Copilot AI commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

MultiThreadedArgument_BuildsProjectReferencesInProcess intermittently failed on Linux when Roslyn shared compilation hit a named-mutex ownership error during concurrent builds.

  • Isolation
    • Disable UseSharedCompilation for this test’s child build.
    • Preserve coverage of multithreaded MSBuild project-reference execution and the single-process assertion.
new DotnetCommand(Log, "build", "Program.cs", argument, "-p:UseSharedCompilation=false")

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
3 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: JeremyKuhne <8184940+JeremyKuhne@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flaky test MultiThreadedArgument_BuildsProjectReferencesInProcess Isolate multithreaded build test from compiler-server mutex race Sep 10, 2026
Copilot AI requested a review from JeremyKuhne September 10, 2026 18:46
@JeremyKuhne
JeremyKuhne marked this pull request as ready for review September 11, 2026 13:59
Copilot AI lite review requested due to automatic review settings September 11, 2026 13:59
@JeremyKuhne
JeremyKuhne requested a review from a team as a code owner September 11, 2026 13:59
@JeremyKuhne
JeremyKuhne enabled auto-merge (squash) September 11, 2026 13:59
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped; the remaining documentation note is non-blocking.

Pull request overview

Isolates a multithreaded build test from Roslyn’s shared-compilation mutex race while preserving its coverage.

Changes:

  • Disables shared compilation for the child build.
  • Retains multithreaded project-reference and single-process assertions.
File summaries
File Description
test/dotnet.Tests/CommandTests/Run/RunFileTests_BuildOptions.cs Adds UseSharedCompilation=false to the targeted build test.
Review details

Suppressed comments (1)

test/dotnet.Tests/CommandTests/Run/RunFileTests_BuildOptions.cs:896

  • This is a test-isolation workaround for the compiler-server mutex race tracked by #56238. Please include the issue URL in the comment so future maintainers can tell when this opt-out can be revisited; otherwise the rationale is easy to lose when the test is updated.
        // Shared compilation uses a named mutex, which is unrelated to testing MSBuild's in-process nodes and can fail independently.
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite


new DotnetCommand(Log, "build", "Program.cs", argument)
// Shared compilation uses a named mutex, which is unrelated to testing MSBuild's in-process nodes and can fail independently.
new DotnetCommand(Log, "build", "Program.cs", argument, "-p:UseSharedCompilation=false")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to understand what the underlying issue here is. Are we just masking a real bug? Also, there are lot of other tests doing dotnet build Program.cs - do we need to add -p:UseSharedCompilation=false to all of them or is only this test flaky for some reason - and if so, what is the reason?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that this masks a real failure. This test is different from the other Program.cs builds because -mt plus two project references runs multiple newly multithreadable Csc tasks in one MSBuild process. In the failing Helix work item, the ordinary file-based builds passed, this -mt row failed, and the -mt:false row passed immediately afterward. The other tests therefore do not need UseSharedCompilation=false.

The exception comes from the Roslyn compiler-server client mutex and matches the failure family previously tracked by dotnet/runtime#53420 and dotnet/dotnet#4088. I opened dotnet/roslyn#85264 for the concurrent shared-compilation scenario and the missing thread-ID diagnostics.

I think disabling shared compilation is still appropriate here to isolate this test's MSBuild in-process-node assertion, but only as a local mitigation. We should not apply it broadly, and the underlying bug remains open in Roslyn.

Note

This response was drafted with GitHub Copilot assistance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for filing the tracking issue. With that I'm fine with this workaround being merged. Consider linking the issue in a code comment near the workaround though.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flaky test] MultiThreadedArgument_BuildsProjectReferencesInProcess fails with MSB3883

5 participants