-
Notifications
You must be signed in to change notification settings - Fork 839
Avoid clearing ResolvedServices #1049
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
Conversation
src/DependencyInjection/DI/src/ServiceLookup/ServiceProviderEngineScope.cs
Outdated
Show resolved
Hide resolved
// Not clearing ResolvedServices here because there might be a compilation running in background | ||
// trying to get a cached singleton service instance and if it won't find | ||
// it it will try to create a new one tripping the Debug.Assert in CaptureDisposable | ||
// and leaking a Disposable object in Release mode |
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.
What should happen in CaptureDisposable if the container is already disposed? Shouldn't we throw an ODE that can be observed by the top-level GetService() call?
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.
It shouldn't get called after dispose. We have ODE checks on all customer accessed entry points. This one is internal that that's why it was able to slip past those checks.
Commit migrated from dotnet/extensions@0947a8d
Commit migrated from dotnet/extensions@0947a8d
Commit migrated from dotnet/extensions@0947a8d
Commit migrated from dotnet/extensions@0947a8d
The race that was happening is the following:
The solution is to keep service cache around and let GC clean it.
Fixes: #1043