Skip to content

Document Unix named mutex scope and storage changes - #56400

Merged
BillWagner merged 4 commits into
mainfrom
copilot/breaking-change-unix-named-mutex
Oct 21, 2026
Merged

BillWagner merged 4 commits into
mainfrom
copilot/breaking-change-unix-named-mutex

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Unix named mutexes now default to user scope, and user-scoped mutex files use user-only directories instead of /tmp. The change applies to .NET 8.0.32, 9.0.21, 10.0.13, and 11.0-rc2.

  • Compatibility article: Documents previous and new behavior, affected versions and APIs, storage locations, and migration guidance.
  • Navigation: Adds the article to the .NET 8–11 compatibility TOCs and indexes.
  • Threading guidance: Clarifies platform-specific named mutex scope and links to the compatibility article.

For applications that require global scope, the runtime configuration option can restore the previous default:

{
  "runtimeOptions": {
    "configProperties": {
      "System.Threading.Mutex.UnsafeDefaultMutexScopeGlobal": true
    }
  }
}

Internal previews

File Preview link
docs/core/compatibility/10.md Learn preview
docs/core/compatibility/11.md Learn preview
docs/core/compatibility/8.0.md Learn preview
docs/core/compatibility/9.0.md Learn preview
docs/core/compatibility/core-libraries/11/named-mutexes-unix-default-scope.md Learn preview
docs/core/compatibility/toc.yml Learn preview
docs/standard/threading/mutexes.md Learn preview
docs/standard/threading/overview-of-synchronization-primitives.md Learn preview

Build report

Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:02

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.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Co-authored-by: BillWagner <[email protected]>
Copilot AI changed the title [WIP] Change default scope and storage location for Unix Named Mutex Document Unix named mutex scope and storage changes Oct 14, 2026
Copilot AI requested a review from BillWagner October 14, 2026 13:15

@BillWagner BillWagner left a comment

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.

This LGTM.

@BillWagner
BillWagner marked this pull request as ready for review October 14, 2026 13:40
@BillWagner
BillWagner requested review from a team and gewarren as code owners October 14, 2026 13:40
@Area51x

Area51x commented Oct 14, 2026

Copy link
Copy Markdown

Thanks for writing this up. I tested the storage-location paragraph ("New behavior", line 22) against runtime 8.0.32 on Linux (mcr.microsoft.com/dotnet/sdk:8.0.426, linux-x64, Debian 12), with XDG_RUNTIME_DIR unset unless noted. Two statements don't match what I observed:

  1. A user-owned $TMPDIR isn't used on Linux. The issue text in [Breaking change]: Unix Named Mutex default scope and storage location changes #56396 says "when on a platform that defines $TMPDIR as a user-scoped directory" (macOS, presumably). The PR changes that to "when it points to a user-owned directory," which reads as if setting TMPDIR to a private directory works. It doesn't.
  2. The fallback is the passwd home directory, not $HOME. $HOME is ignored even when it points to a user-owned, mode-700 directory, and the files go under /.dotnet/corefx/Runtime/SharedMemory/.dotnet/shm. A UID with no passwd entry therefore fails no matter what HOME is set to.
┌───────────────────────────┬────────────────────────────────────┬────────┬───────────────────────────────────────────────────────────┐
│          Run as           │            Environment             │ Result │                       Backing files                       │
├───────────────────────────┼────────────────────────────────────┼────────┼───────────────────────────────────────────────────────────┤
│ UID 1654 (app)            │ TMPDIR=/tmp/t (owned by 1654, 700) │ OK     │ /home/app/.dotnet/corefx/Runtime/SharedMemory/.dotnet/shm │
├───────────────────────────┼────────────────────────────────────┼────────┼───────────────────────────────────────────────────────────┤
│ UID 1654 (app)            │ HOME=/h (owned by 1654, 700)       │ OK     │ /home/app/.dotnet/corefx/...                              │
├───────────────────────────┼────────────────────────────────────┼────────┼───────────────────────────────────────────────────────────┤
│ UID 1000, no passwd entry │ TMPDIR=/tmp/t (owned by 1000, 700) │ Fails  │ —                                                         │
├───────────────────────────┼────────────────────────────────────┼────────┼───────────────────────────────────────────────────────────┤
│ UID 1000, no passwd entry │ HOME=/h (owned by 1000, 700)       │ Fails  │ —                                                         │
├───────────────────────────┼────────────────────────────────────┼────────┼───────────────────────────────────────────────────────────┤
│ UID 1000, no passwd entry │ XDG_RUNTIME_DIR=/tmp/xdg           │ OK     │ /tmp/xdg/.dotnet/shm                                      │
└───────────────────────────┴────────────────────────────────────┴────────┴───────────────────────────────────────────────────────────┘

The failures are System.IO.IOException: The system cannot open the device or file specified. : 'NuGet-Migrations' during SDK first run. That's common in CI, where containers often run with docker run -u $(id -u):$(id -g).

Suggested wording for line 22:

▎ The runtime stores user-scoped mutex backing files in $TMPDIR on platforms where it's a per-user directory (such as macOS). Otherwise, it uses $XDG_RUNTIME_DIR if set; if not, it uses a directory under the current user's home directory as defined in the user database (/etc/passwd), not $HOME.

And an addition to "Recommended action":

▎ If your process runs as a UID with no user database entry, which is common in containers started with docker run -u or Kubernetes runAsUser, named mutex creation fails. Set XDG_RUNTIME_DIR to a writable directory owned by that user, or create a user account for that UID in the image.

I've only tested 8.0.32 on Linux; 9.0, 10.0 and 11.0 may differ.

@BillWagner

Copy link
Copy Markdown
Member

@jkoritzinsky Can you review #56400 (comment) and let us know if anything in this PR should be updated? Thanks.

@jkoritzinsky

Copy link
Copy Markdown
Member

@BillWagner all of the recommendations there are correct. I'd recommend taking them. In particular the last recommendation was something I was going to recommend as another workaround.

All of the feedback from that comment should be integrated into the notice.

@BillWagner

Copy link
Copy Markdown
Member

@copilot Incorporate all the recommendations for workarounds from #56400 (comment) with note on #56400 (comment).

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Incorporate all the recommendations for workarounds from #56400 (comment) with note on #56400 (comment)...

Updated the notice with the storage-path corrections and the workaround for UIDs without a user-database entry. The changes are local and uncommitted for review.

Co-authored-by: BillWagner <[email protected]>

@BillWagner BillWagner left a comment

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.

This LGTM.

@BillWagner
BillWagner merged commit f0021fd into main Oct 21, 2026
13 checks passed
@BillWagner
BillWagner deleted the copilot/breaking-change-unix-named-mutex branch October 21, 2026 15:27
dlevy-msft-sql pushed a commit to dlevy-msft-sql/docs that referenced this pull request Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Breaking change]: Unix Named Mutex default scope and storage location changes

6 participants