dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.16k stars 4.71k forks source link

Trim analyzer should defend against endless loops in analysis #86627

Open vitek-karas opened 1 year ago

vitek-karas commented 1 year ago

The data flow analysis implemented by the analyzer (over CFG) implements a simple algorithm which loops until it hits a steady state. Assuming there no bugs, that should always happen, but if it doesn't the analyzer will effectively hang.

We should implement a guard on the number of iterations and fail (probably even throw) if it happens:

ghost commented 1 year ago

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.

Issue Details
The data flow analysis implemented by the analyzer (over CFG) implements a simple algorithm which loops until it hits a steady state. Assuming there no bugs, that should always happen, but if it doesn't the analyzer will effectively hang. We should implement a guard on the number of iterations and fail (probably even throw) if it happens: * We want to know if this gets hit, since that means there's a bug * We don't want to hang, as that hangs the compiler/IDE and the experience of that is terrible (plus we don't get any info from it, unlike the exception where we could include the name of the method being analyzed for example)
Author: vitek-karas
Assignees: -
Labels: `area-Tools-ILLink`
Milestone: -
vitek-karas commented 1 year ago

We should also implement the same in the trimmer and AOT since those also implement the interprocedural analysis which has one of these algorithms in it.