Skip to content
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

[release/8.0-staging] Fix ILLink/ILC hang when tracking too many hoisted local values #95302

Merged

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Nov 27, 2023

Backport of #95041 to release/8.0-staging

Customer Impact

Fixes a customer-reported hang when using PublishTrimmed in an app that happened to have a large method with a lot of awaits. The same issue is also present with PublishAot.

Testing

Validated fix with a repro testcase.

Risk

Low. The fix can lead to new warnings in some cases (as seen in the analyzer testcase), but these represent potential correctness issues, can be easily silenced if necessary, and should be very rare (only affect very large methods with particular patterns that cause tracking of a large number of dataflow values where we give up on the tracking).

…et#95041)

dotnet#87634 introduced a limit
on the number of values tracked in dataflow analysis, but this
approach was incorrect because resetting the set of tracked
values was effectively moving up the dataflow lattice, breaking
the invariant and causing potential hangs.

The hang was observed in
dotnet#94831, where (as found
by @vitek-karas) the hoisted local `state` field of an async
method with many await points was getting a large number of
tracked values, hitting the limit, being reset to "empty", but
then growing again, causing the analysis not to converge.

The fix is to instead introduce a special value
`ValueSet<TValue>.Unknown` that is used for this case. It acts
like "bottom" in the lattice, so that it destroys any other
inputs on meet ("bottom" meet anything else is "bottom").

In this testcase the `state` field isn't involved in dataflow
warnings, so this actually allows the method to be analyzed
correctly, producing the expected warning for the `Type` local
that flows across all of the await points.

Fixes dotnet#94831
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 27, 2023
@ghost ghost assigned sbomer Nov 27, 2023
@sbomer sbomer added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Nov 27, 2023
@ghost
Copy link

ghost commented Nov 27, 2023

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

Issue Details

Backport of #95041 to release/8.0-staging

Customer Impact

Fixes a customer-reported hang when using PublishTrimmed in an app that happened to have a large method with a lot of awaits. The same issue is also present with PublishAot.

Testing

Validated fix with a repro testcase.

Risk

Low. The fix can lead to new warnings in some cases (as seen in the analyzer testcase), but these represent potential correctness issues, can be easily silenced if necessary, and should be very rare (only affect very large methods with particular patterns that cause tracking of a large number of dataflow values where we give up on the tracking).

Author: sbomer
Assignees: sbomer
Labels:

area-Tools-ILLink, needs-area-label

Milestone: -

@sbomer sbomer added area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 27, 2023
@ghost
Copy link

ghost commented Nov 27, 2023

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

Issue Details

Backport of #95041 to release/8.0-staging

Customer Impact

Fixes a customer-reported hang when using PublishTrimmed in an app that happened to have a large method with a lot of awaits. The same issue is also present with PublishAot.

Testing

Validated fix with a repro testcase.

Risk

Low. The fix can lead to new warnings in some cases (as seen in the analyzer testcase), but these represent potential correctness issues, can be easily silenced if necessary, and should be very rare (only affect very large methods with particular patterns that cause tracking of a large number of dataflow values where we give up on the tracking).

Author: sbomer
Assignees: sbomer
Labels:

area-NativeAOT-coreclr, area-Tools-ILLink

Milestone: -

@sbomer sbomer added the Servicing-consider Issue for next servicing release review label Nov 27, 2023
Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved. we will take for consideration in 8.0.x

@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.x milestone Dec 12, 2023
@rbhanda rbhanda modified the milestones: 8.0.x, 8.0.2 Dec 14, 2023
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Dec 14, 2023
@jeffschwMSFT jeffschwMSFT merged commit 3001c75 into dotnet:release/8.0-staging Jan 2, 2024
131 of 141 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants