Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 89bf443

Browse files
authored
Fix a bug where the DAC read four more bytes than necessary (#7430)
to retrieve gcHeapType, which failed on crash dumps.
1 parent 6409491 commit 89bf443

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/debug/daccess/request.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,31 +2962,19 @@ ClrDataAccess::GetGCHeapData(struct DacpGcHeapData *gcheapData)
29622962

29632963
// for server GC-capable builds only, we need to check and see if IGCHeap::gcHeapType
29642964
// is GC_HEAP_INVALID, in which case we fail.
2965-
// IGCHeap::gcHeapType doesn't exist on non-server-GC capable builds.'
2965+
// IGCHeap::gcHeapType doesn't exist on non-server-GC capable builds.
29662966
#ifdef FEATURE_SVR_GC
2967-
size_t gcHeapValue = 0;
2968-
ULONG32 returned = 0;
2969-
2970-
TADDR gcHeapTypeLocation = m_globalBase + g_dacGlobals.IGCHeap__gcHeapType;
2971-
2972-
// @todo Microsoft: we should probably be capturing the HRESULT from ReadVirtual. We could
2973-
// provide a more informative error message. E_FAIL is a wretchedly vague thing to return.
2974-
hr = m_pTarget->ReadVirtual(gcHeapTypeLocation, (PBYTE)&gcHeapValue, sizeof(gcHeapValue), &returned);
2975-
if (!SUCCEEDED(hr))
2976-
{
2977-
goto cleanup;
2978-
}
2967+
ULONG32 gcHeapValue = IGCHeap::gcHeapType;
29792968

29802969
// GC_HEAP_TYPE has three possible values:
29812970
// GC_HEAP_INVALID = 0,
29822971
// GC_HEAP_WKS = 1,
29832972
// GC_HEAP_SVR = 2
29842973
// If we get something other than that, we probably read the wrong location.
2985-
_ASSERTE(gcHeapValue >= 0 && gcHeapValue <= 2);
2974+
_ASSERTE(gcHeapValue >= IGCHeap::GC_HEAP_INVALID && gcHeapValue <= IGCHeap::GC_HEAP_SVR);
29862975

2987-
//@todo Microsoft: We have an enumerated type, we probably should use the symbolic name
29882976
// we have GC_HEAP_INVALID if gcHeapValue == 0, so we're done
2989-
if (SUCCEEDED(hr) && ((returned != sizeof(gcHeapValue)) || (gcHeapValue == 0)))
2977+
if (gcHeapValue == IGCHeap::GC_HEAP_INVALID)
29902978
{
29912979
hr = E_FAIL;
29922980
goto cleanup;

0 commit comments

Comments
 (0)