Conversation
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
There was a problem hiding this comment.
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 |
...native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Object_1.cs
Outdated
Show resolved
Hide resolved
...ative/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/SyncTableEntry.cs
Outdated
Show resolved
Hide resolved
...ative/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/SyncTableEntry.cs
Show resolved
Hide resolved
...ive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlock_1.cs
Show resolved
Hide resolved
...e/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ISyncBlock.cs
Outdated
Show resolved
Hide resolved
...ive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlock_1.cs
Outdated
Show resolved
Hide resolved
noahfalk
left a comment
There was a problem hiding this comment.
I see copilot spotted a couple implementation issues but modulo those details this looked good to me 👍
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/Object.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Show resolved
Hide resolved
...ive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlock_1.cs
Show resolved
Hide resolved
...ative/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/SyncTableEntry.cs
Show resolved
Hide resolved
...anaged/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlockFactory.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Show resolved
Hide resolved
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
There was a problem hiding this comment.
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
SyncBlockDumpTestssays it covers "SyncBlock (+ Object built-in COM data)", but the test currently only validatesISyncBlocklock ownership/recursion and doesn’t exerciseIObject.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>
...ive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/SyncBlock_1.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
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-nullableTargetPointervalue type, soif (syncBlock.GetSyncBlock(number) is TargetPointer syncBlockAddr && ...)is redundant—theis TargetPointerpattern will always succeed. Assign to a local and compare againstTargetPointer.Nulldirectly 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
namespacedeclaration. Other contract interfaces in this folder consistently include a blank line afternamespace ...;(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
SyncBlockFactoryincludes an unusedusing System;. Please remove it to avoid analyzer warnings / keep the file clean.
using System;
namespace Microsoft.Diagnostics.DataContractReader.Contracts;
No description provided.