Skip to content
Merged
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
Make DacValidateMD more resilient to invalid MethodDesc
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.
  • Loading branch information
janvorli authored and github-actions committed Dec 20, 2022
commit 99a6d6b127cc79d671c6ed49b58cfeac3982da60
7 changes: 6 additions & 1 deletion src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ BOOL DacValidateMD(PTR_MethodDesc pMD)
PTR_MethodTable pMethodTable = pMD->GetMethodTable();

// Standard fast check
if (!pMethodTable->ValidateWithPossibleAV())
if ((pMethodTable == NULL) || dac_cast<TADDR>(pMethodTable) == (TADDR)-1)
{
retval = FALSE;
}

if (retval && !pMethodTable->ValidateWithPossibleAV())
{
retval = FALSE;
}
Expand Down