-
Notifications
You must be signed in to change notification settings - Fork 4.9k
[release/6.0] Unloadability bugs fixes #68674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/6.0] Unloadability bugs fixes #68674
Conversation
This change ports two unloadability fixes for issues found by a customer. * dotnet#68550 that adds reference between native `LoaderAllocator`s of two collectible `AssemblyLoadContexts` when one of them is used to resolve assembly using the other one. This reference ensures that the one that provides the resolved `Assembly` isn't collected before the one that uses it. * dotnet#68336 that adds a missing lock around `m_LoaderAllocatorReferences` iteration during assembly load context destruction.
The change in main has added an exception in case a collectible `Assembly` is resolved into a non-collectible `AssemblyLoadContext`. Although that is incorrect, there are cases when it would work. So the added exception is a breaking change that I think we likely don't want to get into 6.0
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsThis change ports two unloadability fixes for issues found by a customer.
There is one part of #68550 that was intentionally not ported. The change Customer ImpactWithout this change, .NET 6 apps that return collectible Testingcoreclr and libraries tests locally also with GC stress 3 and with runincontext mode. The customer that has reported this issue is testing a patched coreclr.dll with this fix in their environment. RiskLow, it affects only collectible assemblies resolved by one collectible
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Please get a code review and we will take for 6.0.x
Just making sure - have you verified that these cases work the same as before? I understand that these cases are not explicitly throwing an exception. I am worried that this change is not introducing a crash or some other type of bad behavior. |
I have not tried to figure out all the cases where it would accidentally work, so it is hard to answer this question. There was actually one particular case I had in mind. An app explicitly holding a reference to the ALC used for resolving assemblies for the other ALC or the managed |
@jkotas I've tried the case I've mentioned both with and without my change and also with and without GC stress 3. It behaved the same way in both cases. |
Will sync offline with Jan first and then put servicing label after that. |
CI failure is unrelated. |
This change ports two unloadability fixes for issues found by a customer.
LoaderAllocator
s of two collectibleAssemblyLoadContexts
when one ofthem is used to resolve assembly using the other one. This reference
ensures that the one that provides the resolved
Assembly
isn'tcollected before the one that uses it. This port was done manually as some of
the related code was cleaned up in the main and data structures are slightly
different in 6.0.
m_LoaderAllocatorReferences
iteration during assembly load context destruction.
There is one part of #68550 that was intentionally not ported. The change
in main has added an exception in case a collectible
Assembly
is resolved into a non-collectibleAssemblyLoadContext
.Although that is incorrect, there are cases when it would work. So the
added exception is a breaking change that I think we likely don't want
to get into 6.0.
In case we decide to port that breaking change too, we can just remove the 2nd
commit in this PR.
Customer Impact
Without this change, .NET 6 apps that return collectible
Assembly
from theAssemblyLoadContext.Load
override or theAssemblyLoadContext.Resolving
event will likely crash intermittently when operating on the loadedAssembly
.Testing
coreclr and libraries tests locally also with GC stress 3 and with runincontext mode. The customer that has reported this issue is testing a patched coreclr.dll with this fix in their environment.
Risk
Low, it affects only collectible assemblies resolved by one collectible
AssemblyLoadContext
from another collectible one.