Skip to content

[release/11.0] Prevent infinite recursion in ILLink generic dataflow - #134807

Merged
agocke merged 3 commits into
dotnet:release/11.0from
jtschuster:backport-134373-release-11.0
Sep 30, 2026
Merged

agocke merged 3 commits into
dotnet:release/11.0from
jtschuster:backport-134373-release-11.0

Conversation

@jtschuster

Copy link
Copy Markdown
Member

Generic argument dataflow for reflection-visible method and field signatures runs synchronously during marking. A signature such as RequiresPublicMethods can cause dataflow to mark the public members of Self, re-enter the same reflection-visible member, and analyze its signature again indefinitely.

Track reflection-visible members whose signature dataflow is currently in progress a la "visited" set in a DFS. Recursive entry for the same member skips only the duplicate signature analysis; normal marking, dependency recording, and annotation processing still occur.

Customer Impact

Regression

  • Yes
  • No

Testing

Tests that reproduced the issue were added and pass after the fix.

Risk

Low. The fix is small, conceptually simple, and tested. This is unlikely to

Guard reflection-visible member signature analysis against synchronous reentry and add method and field regression coverage.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 6a56a306-481c-4342-ab61-b10611edd9dc
Follow review feedback by tracking active reflection-visible member signature analysis with a stack and asserting LIFO unwinding.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 6a56a306-481c-4342-ab61-b10611edd9dc
Add a method-to-field-to-method cycle that requires tracking the complete active member chain rather than only direct self-recursion.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 6a56a306-481c-4342-ab61-b10611edd9dc
@jtschuster
jtschuster requested a lite review from Copilot September 28, 2026 17:16
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 28, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 28, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Prevents infinite recursion in ILLink generic dataflow for reflection-visible method and field signatures.

Changes:

  • Adds recursion guards for active signature analysis.
  • Preserves normal marking and annotation processing.
  • Adds regression tests for self-referential and mixed cycles.
File Description
src/​tools/​illink/​test/​Mono.Linker.Tests.Cases/​DataFlow/​GenericParameterDataFlowMarking.cs Adds recursion regression coverage.
src/​tools/​illink/​src/​linker/​Linker.Steps/​MarkStep.cs Guards recursive signature dataflow.

@jtschuster
jtschuster marked this pull request as ready for review September 28, 2026 17:30
@jtschuster
jtschuster requested a review from sbomer as a code owner September 28, 2026 17:30
@jtschuster
jtschuster requested a review from agocke September 28, 2026 22:48

@sbomer sbomer left a comment

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.

LGTM, thank you!

@JulieLeeMSFT JulieLeeMSFT added the Servicing-consider Issue for next servicing release review label Sep 29, 2026
@JulieLeeMSFT JulieLeeMSFT added this to the 11.0.0 milestone Sep 29, 2026
@JulieLeeMSFT JulieLeeMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Sep 29, 2026
@agocke

agocke commented Sep 30, 2026

Copy link
Copy Markdown
Member

/ba-g Build Analysis hung

@agocke
agocke merged commit 2db40d8 into dotnet:release/11.0 Sep 30, 2026
114 of 119 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Sep 30, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 31, 2026
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 Servicing-approved Approved for servicing release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants