Skip to content

Commit 6953a9e

Browse files
elinor-fungjtschuster
authored andcommitted
Fix module being set as tenured too early (dotnet#107489)
1 parent b53693b commit 6953a9e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/coreclr/vm/appdomain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,9 @@ DomainAssembly *AppDomain::LoadDomainAssemblyInternal(AssemblySpec* pIdentity,
24812481
fileLock = FileLoadLock::Create(lock, pPEAssembly, pDomainAssembly);
24822482
pDomainAssembly.SuppressRelease();
24832483
pamTracker->SuppressRelease();
2484+
2485+
// Set the assembly module to be tenured now that we know it won't be deleted
2486+
pDomainAssembly->GetAssembly()->SetIsTenured();
24842487
if (pDomainAssembly->IsCollectible())
24852488
{
24862489
// We add the assembly to the LoaderAllocator only when we are sure that it can be added
@@ -2516,7 +2519,9 @@ DomainAssembly *AppDomain::LoadDomainAssemblyInternal(AssemblySpec* pIdentity,
25162519
}
25172520
}
25182521
else
2522+
{
25192523
result->EnsureLoadLevel(targetLevel);
2524+
}
25202525

25212526
// Cache result in all cases, since found pPEAssembly could be from a different AssemblyRef than pIdentity
25222527
if (pIdentity == NULL)

src/coreclr/vm/assembly.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ Assembly *Assembly::CreateDynamic(AssemblyBinder* pBinder, NativeAssemblyNamePar
531531
pLoaderAllocator.SuppressRelease();
532532
}
533533

534+
// Set the assembly module to be tenured now that we know it won't be deleted
534535
pAssem->SetIsTenured();
535536
pRetVal = pAssem;
536537
}

src/coreclr/vm/domainassembly.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoader
5656

5757
// Create the Assembly
5858
NewHolder<Assembly> assembly = Assembly::Create(GetPEAssembly(), GetDebuggerInfoBits(), IsCollectible(), memTracker, IsCollectible() ? GetLoaderAllocator() : NULL);
59-
assembly->SetIsTenured();
6059

6160
m_pAssembly = assembly.Extract();
6261
m_pModule = m_pAssembly->GetModule();

0 commit comments

Comments
 (0)