Skip to content

Commit 934e583

Browse files
authored
Make DacValidateMD more resilient to invalid MethodDesc (#79846)
The DacValidateMD is not resilient to invalid MethodDesc that contains NULL in its m_pMethTab field. It was found when using the ClrMD in the BenchmarkDotNet disassembler code which is trying to find if some constants in the code represent MethodDesc so that it can dump the related method name. This change fixes it by checking the MethodTable after it is extracted from the MethodDesc. There are two values that are not translated between the target and the debugger sides - NULL and -1. So I have added handling both as invalid there.
1 parent 4ee88f0 commit 934e583

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/coreclr/debug/daccess/request.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,12 @@ BOOL DacValidateMD(PTR_MethodDesc pMD)
194194
PTR_MethodTable pMethodTable = pMD->GetMethodTable();
195195

196196
// Standard fast check
197-
if (!pMethodTable->ValidateWithPossibleAV())
197+
if ((pMethodTable == NULL) || dac_cast<TADDR>(pMethodTable) == (TADDR)-1)
198+
{
199+
retval = FALSE;
200+
}
201+
202+
if (retval && !pMethodTable->ValidateWithPossibleAV())
198203
{
199204
retval = FALSE;
200205
}

0 commit comments

Comments
 (0)