Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Microsoft.Diagnostics.Runtime/DacInterface/SosDac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ public string GetFrameName(ulong vtable)

public HResult GetFieldInfo(ulong mt, out MethodTableFieldInfo data)
{
if (mt == 0)
{
data = default;
return HResult.E_INVALIDARG;
}

return VTable.GetMethodTableFieldData(Self, mt, out data);
}

Expand Down Expand Up @@ -420,6 +426,11 @@ public HResult GetAppDomainData(ulong addr, out AppDomainData data)

public string? GetAppDomainName(ulong appDomain)
{
if (appDomain == 0)
{
return null;
}

return GetString(VTable.GetAppDomainName, appDomain);
}

Expand All @@ -436,7 +447,7 @@ public HResult GetAppDomainStoreData(out AppDomainStoreData data)
public HResult GetMethodTableData(ulong addr, out MethodTableData data)
{
// If the 2nd bit is set it means addr is actually a TypeHandle (which GetMethodTable does not support).
if ((addr & 2) == 2)
if (addr == 0 || (addr & 2) == 2)
{
data = default;
return HResult.E_INVALIDARG;
Expand Down Expand Up @@ -662,6 +673,9 @@ public enum ModuleMapTraverseKind

public HResult TraverseModuleMap(ModuleMapTraverseKind mt, ulong module, ModuleMapTraverse traverse)
{
if (module == 0)
return HResult.E_INVALIDARG;
Comment on lines +676 to +677
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Inconsistent brace usage. According to .editorconfig line 275, braces are preferred (csharp_prefer_braces = true:warning). This simple return statement doesn't use braces, but GetFieldInfo (lines 298-302) uses braces for the same pattern. For consistency, consider either using braces here and in GetAppDomainName, or removing braces from GetFieldInfo.

Copilot uses AI. Check for mistakes.

HResult hr = VTable.TraverseModuleMap(Self, mt, module, Marshal.GetFunctionPointerForDelegate(traverse), IntPtr.Zero);
GC.KeepAlive(traverse);
return hr;
Expand All @@ -688,6 +702,9 @@ public enum VCSHeapType

public HResult TraverseStubHeap(ulong heap, VCSHeapType type, LoaderHeapTraverse callback)
{
if (heap == 0)
return HResult.E_INVALIDARG;
Comment on lines +705 to +706
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

Inconsistent brace usage. According to .editorconfig line 275, braces are preferred (csharp_prefer_braces = true:warning). This simple return statement doesn't use braces, but GetFieldInfo (lines 298-302) uses braces for the same pattern. For consistency, consider either using braces here and in GetAppDomainName and TraverseModuleMap, or removing braces from GetFieldInfo.

Copilot uses AI. Check for mistakes.

HResult hr = VTable.TraverseVirtCallStubHeap(Self, heap, type, Marshal.GetFunctionPointerForDelegate(callback));
GC.KeepAlive(callback);
return hr;
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.Diagnostics.Runtime/DacInterface/SosDac8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public SOSDac8(DacLibrary library, IntPtr ptr)

public HResult GetAssemblyLoadContext(ClrDataAddress methodTable, out ClrDataAddress assemblyLoadContext)
{
if (methodTable == 0)
{
assemblyLoadContext = 0;
return HResult.E_INVALIDARG;
}

return VTable.GetAssemblyLoadContext(Self, methodTable, out assemblyLoadContext);
}

Expand Down