Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix incorrect usage of ILCodeVersion::AsNode (issue #18602)
When the debugger is querying the active rejit IL for an IL method that has not been rejitted it incorrectly creates a VMPTR_ILCodeVersionNode for a code version that shouldn't have one.
  • Loading branch information
noahfalk committed Jun 26, 2018
1 parent dda4dbc commit af4ba73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/debug/daccess/dacdbiimpl.cpp
Expand Up @@ -7169,7 +7169,7 @@ HRESULT DacDbiInterfaceImpl::GetActiveRejitILCodeVersionNode(VMPTR_Module vmModu
// manager's active IL version hasn't yet asked the profiler for the IL body to use, in which case we want to filter it
// out from the return in this method.
ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodTk);
if (activeILVersion.IsNull() || activeILVersion.GetRejitState() != ILCodeVersion::kStateActive)
if (activeILVersion.IsNull() || activeILVersion.IsDefaultVersion() || activeILVersion.GetRejitState() != ILCodeVersion::kStateActive)
{
pVmILCodeVersionNode->SetDacTargetPtr(0);
}
Expand Down
6 changes: 6 additions & 0 deletions src/vm/codeversion.cpp
Expand Up @@ -940,13 +940,19 @@ HRESULT ILCodeVersion::SetActiveNativeCodeVersion(NativeCodeVersion activeNative
ILCodeVersionNode* ILCodeVersion::AsNode()
{
LIMITED_METHOD_CONTRACT;
//This is dangerous - NativeCodeVersion coerces non-explicit versions to NULL but ILCodeVersion assumes the caller
//will never invoke AsNode() on a non-explicit node. Asserting for now as a minimal fix, but we should revisit this.
_ASSERTE(m_storageKind == StorageKind::Explicit);
return m_pVersionNode;
}
#endif //DACCESS_COMPILE

PTR_ILCodeVersionNode ILCodeVersion::AsNode() const
{
LIMITED_METHOD_DAC_CONTRACT;
//This is dangerous - NativeCodeVersion coerces non-explicit versions to NULL but ILCodeVersion assumes the caller
//will never invoke AsNode() on a non-explicit node. Asserting for now as a minimal fix, but we should revisit this.
_ASSERTE(m_storageKind == StorageKind::Explicit);
return m_pVersionNode;
}

Expand Down

0 comments on commit af4ba73

Please sign in to comment.