dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.42k stars 198 forks source link

Detect infinite generic expansion #776

Closed hez2010 closed 2 years ago

hez2010 commented 3 years ago

Previous discussion: https://github.com/dotnet/corert/issues/363

We need to detect infinite generic expansion and terminate type loading.

Affected test:

JIT\Methodical\inlining\bug505642\test\

.NET Native for UWP apps uses Tarjan's algorithm to find strongly connected components in the graph of constructed types.

The task is to:

Here's a couple test cases: recursion.zip. We would be able to solve the ones where the recursion happens over reference types. If the recursion happens over value types, this is not solvable without universal shared code.

MichalStrehovsky commented 2 years ago

This is mostly done but I would like to avoid the spurious NullReferenceExceptions when cutoff happens, and I would like the compiler to print some sort of useful feedback when the cutoff happens so that people can ideally remove the generic cycle from the source.

MichalStrehovsky commented 2 years ago

Fixed in #1681, #1699, #1709, #1710.