Skip to content

cDAC: implement GetSyncBlockCleanupData#125009

Merged
rcj1 merged 10 commits intomainfrom
copilot/implement-get-sync-block-cleanup-data
Mar 3, 2026
Merged

cDAC: implement GetSyncBlockCleanupData#125009
rcj1 merged 10 commits intomainfrom
copilot/implement-get-sync-block-cleanup-data

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Implements GetSyncBlockCleanupData and GetSyncBlockData in the cDAC. COM data is read directly from the sync block pointer (not via the object header) since objects on the cleanup list may not be valid managed objects.

Changes

  • SyncBlock_1 — adds GetSyncBlockFromCleanupList(), GetNextSyncBlock(TargetPointer), and GetBuiltInComData(TargetPointer, ...) for cleanup-list traversal and COM data reads directly from a sync block
  • SOSDacImpl.GetSyncBlockCleanupDataaddr==0 walks from cleanup list head; addr!=0 reads the block at that pointer; both paths use SyncBlock.GetBuiltInComData directly
  • SOSDacImpl.GetSyncBlockData — uses SyncBlock contract methods directly instead of going through the object header
  • GetAdditionalThreadCount — returns 0 (conditional weak table traversal is a TODO)
  • SLink — removed from the managed type system (DataType.SLink, Data/SLink.cs); LinkNext encodes the field offset directly in SyncBlockFactory, eliminating the need for a separate SLink type
  • TestsSyncBlockTests covering cleanup-list traversal (single/multi-item, last-item-returns-null) and GetBuiltInComData with/without interop info

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/dotnet/diagnostics/contents/src/tests/SOS
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)
  • https://api.github.com/search/code
    • Triggering command: /usr/bin/curl curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copilot AI and others added 2 commits February 28, 2026 15:17
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
…ockCleanupInfo_RCWLockBitMasked tests

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement cDAC API GetSyncBlockCleanupData Implement cDAC API GetSyncBlockCleanupData Feb 28, 2026
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
… COM data

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
…ct delegates to it; update docs

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
@rcj1
Copy link
Contributor

rcj1 commented Feb 28, 2026

@copilot please apply the following patch.
patch.patch

…to factory, simplify null checks

Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot please apply the following patch.
patch.patch

Applied in b2c0797. Key changes from the patch:

  • Removed the hardcoded SyncBlockValue nested class from Object_1; the bit constants (SyncBlockIsHashOrSyncBlockIndex, SyncBlockIsHashCode, SyncBlockIndexMask) are now runtime globals read via ReadGlobal<uint>, backed by datadescriptor.inc macros (BIT_SBLK_IS_HASH_OR_SYNCBLKINDEX, BIT_SBLK_IS_HASHCODE, MASK_SYNCBLOCKINDEX)
  • Moved syncBlockLinkOffset computation from SyncBlock_1's constructor into SyncBlockFactory
  • Simplified SyncBlockCache.CleanupBlockList to direct field access (removed optional TryGetValue pattern)
  • Moved the data == null check inside the try block in GetSyncBlockCleanupData; removed the addr != 0 guard on the DEBUG assertion
  • Fixed request.cpp to allow syncBlock == 0

@rcj1 rcj1 requested a review from barosiak February 28, 2026 20:55
@rcj1 rcj1 marked this pull request as ready for review February 28, 2026 20:55
Copilot AI review requested due to automatic review settings February 28, 2026 20:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements the GetSyncBlockCleanupData API in the cDAC (Contracts Data for Diagnostics). It also fixes a pre-existing behavior discrepancy: the legacy C++ implementation incorrectly returned E_INVALIDARG for addr=0, while the API contract specifies that addr=0 should start cleanup list traversal from SyncBlockCache.m_pCleanupBlockList. Additionally, it refactors GetBuiltInComData to work directly from a sync block pointer, enabling safe access during cleanup when the associated managed object may not be valid.

Changes:

  • Adds GetSyncBlockFromCleanupList(), GetNextSyncBlock(), and GetBuiltInComData(TargetPointer syncBlock, ...) to the ISyncBlock interface and SyncBlock_1 implementation
  • Refactors Object_1.GetBuiltInComData to delegate to the SyncBlock contract, and moves the sync block bit constants (SyncBlockIsHashOrSyncBlockIndex, SyncBlockIsHashCode, SyncBlockIndexMask) to runtime globals exposed via the data descriptor
  • Adds GetSyncBlockCleanupData implementation in SOSDacImpl using the new SyncBlock contract APIs, and updates GetSyncBlockData to use syncBlock.GetBuiltInComData directly

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ISyncBlock.cs Adds three new cleanup-list and COM-data interface methods
SyncBlock_1.cs Implements new methods; receives syncBlockLinkOffset for list pointer arithmetic
SyncBlockFactory.cs Computes and passes syncBlockLinkOffset to SyncBlock_1
Object_1.cs Removes SyncBlockValue nested class; reads bit constants from runtime globals; delegates GetBuiltInComData to ISyncBlock
SOSDacImpl.cs Implements GetSyncBlockCleanupData; updates GetSyncBlockData to use SyncBlock contract
ISOSDacInterface.cs Adds DacpSyncBlockCleanupData struct; updates GetSyncBlockCleanupData signature
Constants.cs Adds three new SyncBlock* global name constants
SyncBlockCache.cs Adds CleanupBlockList field
datadescriptor.inc Exposes SyncBlockCache.CleanupBlockList and three bit constants as globals
syncblk.h Adds CleanupBlockList to cdac_data<SyncBlockCache>
request.cpp Removes syncBlock == 0 from E_INVALIDARG guard
SyncBlockTests.cs New unit tests for cleanup list traversal and COM data
MockDescriptors.SyncBlock.cs New test descriptor for SyncBlock cleanup list
MockDescriptors.Object.cs Adds three new globals to Object mock
MockDescriptors.cs Adds CleanupBlockList to SyncBlockCacheFields
SyncBlock.md Documents new APIs, data descriptors
Object.md Documents new globals and delegation pattern

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rcj1
Copy link
Contributor

rcj1 commented Mar 3, 2026

@copilot do you know why the build and test is stalling https://dev.azure.com/dnceng-public/public/_build/results?buildId=1316850

Copy link
Contributor Author

Copilot AI commented Mar 3, 2026

@copilot do you know why the build and test is stalling https://dev.azure.com/dnceng-public/public/_build/results?buildId=1316850

The build isn't stalled — it spent about 7+ hours in the queue (queued at 21:44 UTC, started running at ~04:58 UTC) and has been executing normally since then. As of now, 5 of 7 jobs have completed successfully; the remaining 2 (cDAC_windows_x64_release/DAC_windows_x64_release and Build / Test) are still in progress. No failures yet. The long delay was queue wait time, not a stuck build.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh pr checks 115337 --repo dotnet/runtime (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of rcj1 March 3, 2026 07:05
Copilot finished work on behalf of rcj1 March 3, 2026 07:17
Copilot AI changed the title Implement cDAC API GetSyncBlockCleanupData cDAC: implement GetSyncBlockCleanupData and GetSyncBlockData Mar 3, 2026
Copilot finished work on behalf of rcj1 March 3, 2026 07:37
@rcj1 rcj1 changed the title cDAC: implement GetSyncBlockCleanupData and GetSyncBlockData cDAC: implement GetSyncBlockCleanupData Mar 3, 2026
@rcj1
Copy link
Contributor

rcj1 commented Mar 3, 2026

/ba-g unrelated fails

@rcj1 rcj1 merged commit 523aab9 into main Mar 3, 2026
110 of 115 checks passed
@rcj1 rcj1 deleted the copilot/implement-get-sync-block-cleanup-data branch March 3, 2026 18:32
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.

5 participants