Repository navigation
Scope compiler server mutexes per-user - #86056
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
Mutex ACL behavior is security-sensitive across Windows, .NET Framework, and Unix, and CI remains in progress.
0 open findings
What changed in this PR
Scopes compiler-server mutexes per user while preserving cross-user cache coordination.
Changes:
- Adds modern .NET and .NET Framework user isolation.
- Adds platform-specific mutex tests.
- Documents cache mutex scope.
Holistic assessment: No concrete defects found, but the security-sensitive, cross-framework behavior warrants human validation.
| File | Description |
|---|---|
BuildServerConnection.cs |
Implements per-user mutex creation and validation. |
ServerNamedMutexTests.cs |
Tests user and legacy mutex scopes. |
CompilationCacheTests.cs |
Preserves cross-user cache test locking. |
BuildServerConnectionTests.cs |
Updates tests to use scoped mutexes. |
CompilationCache.cs |
Keeps cache-entry mutexes cross-user. |
compiler-output-cache-experiment.md |
Documents cache path and mutex scope. |
🧠 Review effort: Balanced
|
|
||
| Per-entry synchronization is used so that multiple writers racing on the same key do not all try to publish the same result concurrently. If another process is already populating an entry, the current request simply continues with normal compilation behavior. | ||
|
|
||
| Cache-entry mutexes use cross-session, cross-user scope so processes sharing a cache directory use the same locks, subject to operating-system access controls. This differs from compiler-server startup and lifetime mutexes, which are restricted to the current user. Mutex scope does not replace access controls on the cache directory. |
There was a problem hiding this comment.
Consider moving this comment to the TryAcquireEntryMutex code in CompilationCache. Otherwise, the currentUserOnly: false stands out a bit.
|
|
||
| ```text | ||
| <temp>/roslyn-cache | ||
| <LocalApplicationData>/roslyn-cache |
There was a problem hiding this comment.
Should we use well-known user cache dirs instead?
There was a problem hiding this comment.
Yes, I can look into that, thanks. That seems orthogonal to this PR though.
|
@333fred for another look, thanks |
| var mutexName = GetCacheEntryMutexName(dllName, hashKey); | ||
| if (!createIfMissing && !ServerNamedMutex.WasOpen(mutexName)) | ||
| if (!createIfMissing && !ServerNamedMutex.WasOpen(mutexName, currentUserOnly: false)) |
There was a problem hiding this comment.
Can you actually fulfill the requirements here? Docs say that all users on the machine must be trusted to use global mutexes.
The corresponding named pipes are already per-user. On non-Windows, per-user is now the default anyway, so this PR unifies the Windows behavior.
cc @jaredpar @agocke
Microsoft Reviewers: Open in CodeFlow