Skip to content

Add GetSyncBlockData cDAC API#124933

Merged
rcj1 merged 20 commits intodotnet:mainfrom
rcj1:GetSyncBlockData
Feb 28, 2026
Merged

Add GetSyncBlockData cDAC API#124933
rcj1 merged 20 commits intodotnet:mainfrom
rcj1:GetSyncBlockData

Conversation

@rcj1
Copy link
Contributor

@rcj1 rcj1 commented Feb 27, 2026

No description provided.

@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.

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 adds a new SyncBlock contract to the cDAC (Contract Data Access Component) system, enabling inspection of sync blocks, lock state, and COM interop data from memory dumps. The implementation introduces the GetSyncBlockData SOS DAC API and supporting infrastructure.

Changes:

  • Adds ISyncBlock contract with APIs for reading sync block table entries, lock ownership, recursion counts, and waiting thread counts
  • Implements GetSyncBlockData in SOSDacImpl to retrieve comprehensive sync block information
  • Extends GetBuiltInComData to return CCF (COM Callable Factory) pointer in addition to existing RCW/CCW pointers

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ISyncBlock.cs Defines contract interface for sync block operations
SyncBlock_1.cs Implements version 1 of SyncBlock contract with lock info retrieval
SyncBlockFactory.cs Factory for creating SyncBlock contract instances
CachingContractRegistry.cs Registers SyncBlock contract in the registry
SOSDacImpl.cs Implements GetSyncBlockData ISOSDacInterface method with debug validation
ISOSDacInterface.cs Defines DacpSyncBlockData structure and updates GetSyncBlockData signature
SyncTableEntry.cs Adds Object field to read associated object pointer
SyncBlockCache.cs New data class for reading sync block cache metadata
SyncBlock.cs Extends sync block data with Lock, ThinLock, and LinkNext fields
SLink.cs New data class for waiting thread linked list traversal
Object.cs Adds Address and Data fields for field offset calculations
InteropSyncBlockInfo.cs Adds CCF (COM Callable Factory) field
Object_1.cs Updates GetBuiltInComData to return CCF and handle CCW sentinel
RuntimeTypeSystem_1.cs Adds GetFieldDescByName for field lookup by name
Constants.cs Adds SyncBlock-related global constants
DataType.cs Adds SLink and SyncBlockCache data types
IObject.cs Updates GetBuiltInComData signature with CCF parameter
IRuntimeTypeSystem.cs Adds GetFieldDescByName API
ContractRegistry.cs Exposes SyncBlock contract property
Lock.cs Documents cDAC dependency on field names
syncblk.h Adds cdac_data structures for SyncBlock and SyncBlockCache
datadescriptor.inc Registers SyncBlock contract and related data types
SyncBlock.md New documentation for SyncBlock contract
Object.md Updates GetBuiltInComData documentation with CCF
ObjectTests.cs Updates COM data test with CCF validation
SyncBlockDumpTests.cs New dump test for sync block lock contention
SyncBlockInterop/Program.cs New debuggee creating lock contention scenario
SyncBlockInterop.csproj New debuggee project file
README.md Documents new SyncBlockInterop debuggee and test

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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 8 comments.

@rcj1 rcj1 requested a review from jkoritzinsky February 27, 2026 01:55
Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

I see copilot spotted a couple implementation issues but modulo those details this looked good to me 👍

Copilot AI review requested due to automatic review settings February 27, 2026 17:47
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

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings February 27, 2026 19:44
Copilot AI review requested due to automatic review settings February 27, 2026 21:46
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

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

Copilot AI review requested due to automatic review settings February 28, 2026 02:38
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/native/managed/cdac/tests/DumpTests/README.md:61

  • The table entry for SyncBlockDumpTests says it covers "SyncBlock (+ Object built-in COM data)", but the test currently only validates ISyncBlock lock ownership/recursion and doesn’t exercise IObject.GetBuiltInComData. Either update the description to match the test, or add assertions that cover the built-in COM data behavior if that’s intended here.
| PInvokeStubDumpTests | StackWalk + RTS | PInvokeStub |
| VarargPInvokeDumpTests | StackWalk + RTS | VarargPInvoke |
| SyncBlockDumpTests | SyncBlock (+ Object built-in COM data) | SyncBlock |

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 28, 2026 02:47
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings February 28, 2026 04:48
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

Copilot reviewed 33 out of 34 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs:3438

  • syncBlock.GetSyncBlock(number) returns a non-nullable TargetPointer value type, so if (syncBlock.GetSyncBlock(number) is TargetPointer syncBlockAddr && ...) is redundant—the is TargetPointer pattern will always succeed. Assign to a local and compare against TargetPointer.Null directly to avoid analyzer warnings and improve readability.
                    TargetPointer obj = syncBlock.GetSyncBlockObject(number);
                    data->Object = obj.ToClrDataAddress(_target);
                    if (syncBlock.GetSyncBlock(number) is TargetPointer syncBlockAddr && syncBlockAddr != TargetPointer.Null)
                    {
                        data->SyncBlockPointer = syncBlockAddr.ToClrDataAddress(_target);

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ISyncBlock.cs:8

  • This file is missing a blank line after the file-scoped namespace declaration. Other contract interfaces in this folder consistently include a blank line after namespace ...; (e.g., IObject.cs, IGCInfo.cs), and some builds enforce this via analyzers.
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
public interface ISyncBlock : IContract
{

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlockFactory.cs:6

  • SyncBlockFactory includes an unused using System;. Please remove it to avoid analyzer warnings / keep the file clean.
using System;

namespace Microsoft.Diagnostics.DataContractReader.Contracts;

@rcj1 rcj1 merged commit e756eed into dotnet:main Feb 28, 2026
156 of 162 checks passed
@rcj1 rcj1 deleted the GetSyncBlockData branch February 28, 2026 07:37
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