Skip to content

Commit

Permalink
Fix module being set as tenured too early (dotnet#107489)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung committed Sep 9, 2024
1 parent 2fb3629 commit 0c33c6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,9 @@ DomainAssembly *AppDomain::LoadDomainAssemblyInternal(AssemblySpec* pIdentity,
fileLock = FileLoadLock::Create(lock, pPEAssembly, pDomainAssembly);
pDomainAssembly.SuppressRelease();
pamTracker->SuppressRelease();

// Set the assembly module to be tenured now that we know it won't be deleted
pDomainAssembly->GetAssembly()->SetIsTenured();
if (pDomainAssembly->IsCollectible())
{
// We add the assembly to the LoaderAllocator only when we are sure that it can be added
Expand Down Expand Up @@ -2516,7 +2519,9 @@ DomainAssembly *AppDomain::LoadDomainAssemblyInternal(AssemblySpec* pIdentity,
}
}
else
{
result->EnsureLoadLevel(targetLevel);
}

// Cache result in all cases, since found pPEAssembly could be from a different AssemblyRef than pIdentity
if (pIdentity == NULL)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ Assembly *Assembly::CreateDynamic(AssemblyBinder* pBinder, NativeAssemblyNamePar
pLoaderAllocator.SuppressRelease();
}

// Set the assembly module to be tenured now that we know it won't be deleted
pAssem->SetIsTenured();
pRetVal = pAssem;
}
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/domainassembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ DomainAssembly::DomainAssembly(PEAssembly* pPEAssembly, LoaderAllocator* pLoader

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

m_pAssembly = assembly.Extract();
m_pModule = m_pAssembly->GetModule();
Expand Down

0 comments on commit 0c33c6f

Please sign in to comment.