Skip to content

Commit 9292b45

Browse files
authored
Making sure the nativeCodeVersion flowing change works with Rejit and EnC (dotnet#21961)
1 parent 8b7d300 commit 9292b45

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/debug/ee/functioninfo.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// Licensed to the .NET Foundation under one or more agreements.
23
// The .NET Foundation licenses this file to you under the MIT license.
34
// See the LICENSE file in the project root for more information.
@@ -938,6 +939,8 @@ void DebuggerJitInfo::LazyInitBounds()
938939

939940
LOG((LF_CORDB,LL_EVERYTHING, "DJI::LazyInitBounds: this=0x%x GetBoundariesAndVars success=0x%x\n", this, fSuccess));
940941

942+
// SetBoundaries uses the CodeVersionManager, need to take it now for lock ordering reasons
943+
CodeVersionManager::TableLockHolder lockHolder(mdesc->GetCodeVersionManager());
941944
Debugger::DebuggerDataLockHolder debuggerDataLockHolder(g_pDebugger);
942945

943946
if (!m_fAttemptInit)
@@ -1064,6 +1067,8 @@ void DebuggerJitInfo::SetBoundaries(ULONG32 cMap, ICorDebugInfo::OffsetMapping *
10641067
// Pick a unique initial value (-10) so that the 1st doesn't accidentally match.
10651068
int ilPrevOld = -10;
10661069

1070+
_ASSERTE(m_nativeCodeVersion.GetMethodDesc()->GetCodeVersionManager()->LockOwnedByCurrentThread());
1071+
10671072
InstrumentedILOffsetMapping mapping;
10681073

10691074
ILCodeVersion ilVersion = m_nativeCodeVersion.GetILCodeVersion();
@@ -1614,7 +1619,12 @@ DebuggerJitInfo *DebuggerMethodInfo::FindOrCreateInitAndAddJitInfo(MethodDesc* f
16141619
CodeVersionManager::TableLockHolder lockHolder(fd->GetCodeVersionManager());
16151620
CodeVersionManager *pCodeVersionManager = fd->GetCodeVersionManager();
16161621
NativeCodeVersion nativeCodeVersion = pCodeVersionManager->GetNativeCodeVersion(fd, startAddr);
1617-
_ASSERTE(!nativeCodeVersion.IsNull());
1622+
1623+
// Some day we'll get EnC to use code versioning properly, but until then we'll get the right behavior treating all EnC versions as the default native code version.
1624+
if (nativeCodeVersion.IsNull())
1625+
{
1626+
nativeCodeVersion = NativeCodeVersion(fd);
1627+
}
16181628

16191629
BOOL jitInfoWasCreated;
16201630
return CreateInitAndAddJitInfo(nativeCodeVersion, startAddr, &jitInfoWasCreated);

0 commit comments

Comments
 (0)