-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix NullReferenceException in background thread emitting IL in Depend… #55340
Conversation
…encyInjection When ILEmitResolverBuilder is getting created, it grabs the "Root" scope off of the ServiceProvider. However, the Root scope isn't set on ServiceProvider yet. So later when it tries to get used, it null refs. But this exception gets caught an eaten since it happens on a background thread. The fix is to set Root before creating the ServiceProviderEngine.
Tagging subscribers to this area: @eerhardt, @maryamariyan Issue Details…encyInjection When ILEmitResolverBuilder is getting created, it grabs the "Root" scope off of the ServiceProvider. However, the Root scope isn't set on ServiceProvider yet. So later when it tries to get used, it null refs. But this exception gets caught an eaten since it happens on a background thread. The fix is to set Root before creating the ServiceProviderEngine.
|
I'm betting this it the cause of the performance regression on ARM. |
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceProvider.cs
Show resolved
Hide resolved
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.
One small nit
What do you think about adding a Debug.Assert to https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/DynamicServiceProviderEngine.cs#L39 ? |
…nd compilation thread
|
…encyInjection
When ILEmitResolverBuilder is getting created, it grabs the "Root" scope off of the ServiceProvider. However, the Root scope isn't set on ServiceProvider yet. So later when it tries to get used, it null refs. But this exception gets caught an eaten since it happens on a background thread.
The fix is to set Root before creating the ServiceProviderEngine.
See description of the issue in #55255 (comment).