Skip to content

Commit 8b38c19

Browse files
authored
Fix unloadability (#58948)
There is a bug in AppDomain::FindAssembly code path that iterates over the domain assemblies. The iteration loop leaves the refcount of the LoaderAllocator related to the returned DomainAssembly bumped, but nothing ever decrements it. So when a code that needs to be unloaded ends up in that code path, all the managed things like managed LoaderAllocator, LoaderAllocatorScout are destroyed, but the unloading doesn't complete due to the refcount. We have never found it before as this code path is never executed in any of the coreclr tests even with unloadability testing option.
1 parent 91f4366 commit 8b38c19

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/coreclr/vm/appdomain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,8 +3251,8 @@ DomainAssembly * AppDomain::FindAssembly(PEAssembly * pFile, FindAssemblyOptions
32513251
!pManifestFile->IsResource() &&
32523252
pManifestFile->Equals(pFile))
32533253
{
3254-
// Caller already has PEAssembly, so we can give DomainAssembly away freely without AddRef
3255-
return pDomainAssembly.Extract();
3254+
// Caller already has PEAssembly, so we can give DomainAssembly away freely without added reference
3255+
return pDomainAssembly.GetValue();
32563256
}
32573257
}
32583258
return NULL;

0 commit comments

Comments
 (0)