Skip to content

[ILLink analyzer] Fix dataflow tracking for nested finally regions - #94101

Merged
sbomer merged 2 commits into
dotnet:mainfrom
sbomer:exceptionFix
Nov 1, 2023
Merged

sbomer merged 2 commits into
dotnet:mainfrom
sbomer:exceptionFix

Conversation

@sbomer

@sbomer sbomer commented Oct 27, 2023

Copy link
Copy Markdown
Member

Fixes a bug I encountered while adding some new tests for feature checks.

While analyzing finally regions in the mode where they will not exit normally, we weren't correctly propagating dataflow states through nested finally regions. See dotnet/linker#2481 for original context around the analysis done here.

@sbomer
sbomer requested review from agocke and vitek-karas October 27, 2023 18:16
@sbomer
sbomer requested a review from marek-safar as a code owner October 27, 2023 18:16
@ghost ghost added linkable-framework Issues associated with delivering a linker friendly framework area-Tools-ILLink .NET linker development as well as trimming analyzers labels Oct 27, 2023
@ghost ghost assigned sbomer Oct 27, 2023
@ghost

ghost commented Oct 27, 2023

Copy link
Copy Markdown

Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr, @marek-safar
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes a bug I encountered while adding some new tests for feature checks.

While analyzing finally regions in the mode where they will not exit normally, we weren't correctly propagating dataflow states through nested finally regions. See dotnet/linker#2481 for original context around the analysis done here.

Author: sbomer
Assignees: -
Labels:

linkable-framework

Milestone: -

ProducedBy = Tool.Analyzer)]
[ExpectedWarning ("IL2072", nameof (RequireAll2) + "(Type)", nameof (GetWithPublicMethods) + "()")]
[ExpectedWarning ("IL2072", nameof (RequireAll2) + "(Type)", nameof (GetWithPublicFields) + "()")]
static void CatchInFinally () {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is just a test I added while looking at the related logic.

} finally {
t = GetWithPublicFields ();
}
RequireAll3 (t); // fields only

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Before this fix, RequireAll3 was warning about GetWithPublicMethods not satisfying All.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to confirm - the warning was raised when processing the finally exception state, right? The "normal" state path didn't produce the warning because it already propagates it through predecessor's finally blocks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's right on both counts

Extract code to shared helper
@sbomer

sbomer commented Nov 1, 2023

Copy link
Copy Markdown
Member Author

Failure is #94281

@sbomer
sbomer merged commit e69d338 into dotnet:main Nov 1, 2023
@sbomer
sbomer deleted the exceptionFix branch November 3, 2023 18:45
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2023
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 linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants