dotnet / linker

387 stars 134 forks source link

[release/7.0] Fix endless loop in illink analyzer #3217

Closed vitek-karas closed 1 year ago

vitek-karas commented 1 year ago

This is a port of the 8.0 change: https://github.com/dotnet/runtime/pull/86449

I verified that the repro from https://github.com/dotnet/runtime/issues/86379 is fixed with this change.

This is a 7.0 fix of https://github.com/dotnet/runtime/issues/86379

Impact

If the right pattern occurs in the analyzed code, the analyzer will hang. This leads to hanging the build as well as causing problems with IDEs relying on a language service with the analyzer.

Workaround

The only workaround is to disable the trim analyzer on the affected project - which means losing all of the diagnostics it provides.

Risk

The fix is slightly risky in that it changes how some internal state of the analyzer is maintained (makes more things immutable). The fix has been merged into .NET 8 main for about 2 weeks now and we haven't seen any problems with it.

/cc @agocke