-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Circular reference results in deadlock #36458
Comments
I think we should remove the stack guard. |
Is there a current workaround for this (aside from removing the circular references)? |
No there’s no workaround. |
As part of the migration of components from dotnet/extensions to dotnet/runtime (aspnet/Announcements#411) we will be bulk closing some of the older issues. If you are still interested in having this issue addressed, just comment and the issue will be automatically reactivated (even if you aren't the author). When you do that, I'll page the team to come take a look. If you've moved on or workaround the issue and no longer need this change, just ignore this and the issue will be closed in 7 days. If you know that the issue affects a package that has moved to a different repo, please consider re-opening the issue in that repo. If you're unsure, that's OK, someone from the team can help! |
I have just come across this issue so it still needs looking at. |
Paging @dotnet/extensions-migration ! This issue has been revived from staleness. Please take a look and route to the appropriate repository. |
Could be similar to #35986 |
@maryamariyan - was this fixed with your deadlock work in 6.0? Moving to 7.0, in case it wasn't. But please close if this is fixed in the latest. |
No this isn't fixed. |
I'm on net5 using M.E.DI 6.0.0-preview7 and exactly got that deadlock on StackGuard>WaitOne yesterday :-| |
I believe I also just fell in this hole, on net6.0. Took quite some digging around to figure out that a circular reference was the culprit, I was certain we'd get an exception from the DI container if that happened and didn't even look at that when I started my investigation 🙈 |
The fix here is easy but adds overhead. We should prototype something. If anybody wants to look at this, we do a cycle check when building up the callsite, this only detects cycles in constructor visible dependencies at startup. This doesn't work for runtime resolved dependencies as the |
Is there a work around to detect this during run time? |
Moved from #105900 Possible solution
Edit: seeing this issue has been open for years, I doubt the solution is simple. This interests me. :) Edit2: tried that fix but it doesn't work. Btw it took me 3 hours just to set up the project and pass the tests. |
@davidfowl Edit: there was a false circle detection when resolving the same type with different keys. The 2nd commit fixes that by using ServiceIdentifier instead of Type. |
Is there any reason you didn't do the check in the CallSiteRuntimeResolver? |
I tried that initially but it doesn't work. Storing the state in the |
Wouldn't it be state on the RuntimeResolverContext? |
@davidfowl |
How should we proceed with implementing the fix? |
In 3.0 we rewrote the code generation logic in the DI container to make it resillent to stack overflows for deep object graphs. As a result of this change, what would previously result in a stackoverflow exception for lazily resolved circular references now results in
an infinite recursion. We're missing a number of stacks maximum.a deadlock.The text was updated successfully, but these errors were encountered: