-
Notifications
You must be signed in to change notification settings - Fork 214
Detect generic recursion in generic lookups #1699
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
Detect generic recursion in generic lookups #1699
Conversation
|
Thanks. After this PR all tests in #776 will pass if I reduce the generic recursion depth to 4. |
Awesome, thanks for checking on this! Let's keep the issue open until there's a good feedback experience around this - I would like to avoid the spurious
It's currently hardcoded to 4: runtimelab/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs Lines 34 to 42 in 748d4b3
It would be nice to have it configurable. If you're interested in contributing that, I think we can pipe that through by:
|
|
BTW, how about allowing users to specify the cutoff depth per type/method in rd.xml, while also providing an option for setting default global cutoff depth? <Type Name="Foo`1[[!!0]]" MaxGenericDepth="4" />
<Type Name="Foo">
<Method Name="Bar`1[[System.Int32,System.Private.CoreLib], [!!0]]" MaxGenericDepth="8" />
</Type> |
|
Do you have a motivating example where we would need this to be controllable by type/method? Having just one generic recursion in the program is already bad enough. Having two different recursions that also need different cutoff points sounds like a nightmare scenario. |
Eliminate commas early in block morphing, before the rest of the transformation needs to look at it. Do this by extracting their side effects and adding them on top of the returned result instead. This allows us to handle arbitrary COMMAs on destination operand in a general manner. Prerequisite to #83388. Fix #1699.
We currently cut off generic recursion at two spots:
Method<T>callsMethod<Gen<T>>andGenis a struct).Genis a class).There's yet another variation of this - indirect call to something that causes a recursion. Above two won't capture this because indirect calls don't go through the codepath 1, and codepath 2 is already too late (the recursion happens within the canonical code we already generated and invalidating dictionary entries is too late).
This adds one more spot to cut things off.
This is hit in Npgsql, but only on Linux, for whatever reason.