diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index dc13cf59a7f006..02bb3dcd3f5f57 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -476,7 +476,16 @@ ULONG32 DacDbiInterfaceImpl::GetCountOfInternalFrames(VMPTR_Thread vmThread) InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); +#ifdef TARGET_64BIT + // On 64-bit platforms, an unmanaged calli target is encoded as (target << 1) | 1, + // so bit 0 must be checked first to distinguish it from a MethodDesc pointer with + // the InlinedCallFrameMarker::ExceptionHandlingHelper bit set. Otherwise, an odd + // calli target's shifted-in low bit can be misread as the marker. + if ((datum & 0x1) == 0 && + (datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) +#else if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) +#endif // TARGET_64BIT { pFrame = pFrame->Next(); continue; @@ -529,7 +538,16 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); +#ifdef TARGET_64BIT + // On 64-bit platforms, an unmanaged calli target is encoded as (target << 1) | 1, + // so bit 0 must be checked first to distinguish it from a MethodDesc pointer with + // the InlinedCallFrameMarker::ExceptionHandlingHelper bit set. Otherwise, an odd + // calli target's shifted-in low bit can be misread as the marker. + if ((datum & 0x1) == 0 && + (datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) +#else if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) +#endif // TARGET_64BIT { pFrame = pFrame->Next(); continue;