Skip to content

[release/10.0] Prevent clipboard hangs during concurrent data-store access - #15334

Merged
Shyam-Gupta merged 1 commit into
release/10.0from
dev/shgu/clipHangVS
Oct 29, 2026
Merged

Shyam-Gupta merged 1 commit into
release/10.0from
dev/shgu/clipHangVS

Conversation

@Shyam-Gupta

@Shyam-Gupta Shyam-Gupta commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Fixes 3084829

Backport of #15319 to release/10.0

/cc @Shyam-Gupta @nareshjo

Root Cause

The clipboard data store reads, writes, and enumerates its format dictionary without synchronization. Concurrent mutation can corrupt dictionary state; on .NET Framework, a corrupted bucket chain can cause a later lookup to loop indefinitely.

Proposed changes

  • Protect the clipboard data store's format dictionary against overlapping managed calls and COM callbacks.
  • Capture complete entries and coherent format snapshots while keeping validation, deserialization, and format mapping outside the per-store gate.
  • Cover concurrent insertion and overwrites, callback reentrancy, format compatibility, and native storage-medium ownership with regression tests.

Customer Impact

  • The synchronization gap was identified while investigating customer-reported clipboard hangs. This change addresses a dictionary-corruption race that can cause clipboard operations to fail or hang.
  • Existing format mapping and native drag-and-drop ownership behavior are preserved; no public API changes.

Regression?

  • Unconfirmed. The unsynchronized dictionary predates this change; an introducing release has not been established.

Risk

Low expected compatibility risk. The per-store gate protects dictionary access and snapshot creation; validation, deserialization, format mapping, and explicit COM calls stay outside locked sections. Payload ownership is unchanged. Lock contention and larger snapshots add potential performance costs.

Test methodology

  • Exercise colliding concurrent insertions, concurrent reads and overwrites, complete data/flag publication, and coherent format enumeration.
  • Verify validation and deserialization callbacks can wait for another thread to access the store. Check format mapping/order, validation failures, serializable first-entry behavior, and native-medium ownership.
  • Rebuild the affected test project with the repository's Arcade workflow in Debug and Release. Run the final DataStore regression tests on both targets: 10 Framework cases and 11 modern .NET cases per configuration, totaling 42 passes with no failures or skips.
  • Exercise the exact timeout-cleanup block in an isolated Framework harness with completed, cancellable, and delayed workers. All three checks passed; this checks cleanup behavior, not product COM contention.
  • Basic copy/paste and undo smoke checks with a consumer using the same production fix completed without observed failures. The original intermittent hang has not been reproduced and verified fixed.
Microsoft Reviewers: Open in CodeFlow

@Shyam-Gupta
Shyam-Gupta requested a review from a team as a code owner October 29, 2026 21:16
@Shyam-Gupta Shyam-Gupta self-assigned this Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.11322%. Comparing base (d593d78) to head (c29f965).
⚠️ Report is 3 commits behind head on release/10.0.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           release/10.0      #15334         +/-   ##
======================================================
- Coverage      77.11978%   77.11322%   -0.00657%     
======================================================
  Files              3275        3275                 
  Lines            645221      645237         +16     
  Branches          47716       47717          +1     
======================================================
- Hits             497593      497563         -30     
- Misses           143950      143990         +40     
- Partials           3678        3684          +6     
Flag Coverage Δ
Debug 77.11322% <100.00000%> (-0.00657%) ⬇️
integration 18.98803% <89.74359%> (-0.01743%) ⬇️
production 51.93735% <100.00000%> (-0.01331%) ⬇️
test 97.40930% <ø> (ø)
unit 49.35676% <100.00000%> (+0.00628%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Shyam-Gupta Shyam-Gupta added servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria area-Clipboard Issues related to Clipboard labels Oct 29, 2026
@Shyam-Gupta

Copy link
Copy Markdown
Member Author

Approved over email.

@Shyam-Gupta Shyam-Gupta added servicing-approved .NET Shiproom approved the PR for merge and removed servicing-consider .NET Shiproom label indicating a PR seeks to enter into a branch under Tell-Mode criteria labels Oct 29, 2026
@Shyam-Gupta
Shyam-Gupta merged commit a2152ed into release/10.0 Oct 29, 2026
10 checks passed
@Shyam-Gupta
Shyam-Gupta deleted the dev/shgu/clipHangVS branch October 29, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Clipboard Issues related to Clipboard servicing-approved .NET Shiproom approved the PR for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants