Skip to content

Commit 88cff5e

Browse files
Make DacValidateMD more resilient to invalid MethodDesc (#79862)
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. Co-authored-by: Jan Vorlicek <[email protected]>
1 parent 8db9e3d commit 88cff5e

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
@@ -195,7 +195,12 @@ BOOL DacValidateMD(PTR_MethodDesc pMD)
195195
PTR_MethodTable pMethodTable = pMD->GetMethodTable();
196196

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

0 commit comments

Comments
 (0)