Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle ILLink origins before first sequence point#129869

Open
sbomer wants to merge 2 commits into
dotnet:main from
sbomer:runtime-illink-crash
Open

Handle ILLink origins before first sequence point #129869
sbomer wants to merge 2 commits into
dotnet:main from
sbomer:runtime-illink-crash

Conversation

@sbomer

@sbomer sbomer commented Jun 25, 2026
edited
Loading

Copy link
Copy Markdown
Member

Fixes #129562.

MessageOrigin.ToString() assumed that every diagnostic IL offset has at least one PDB sequence point at or before that offset. Rewritten/generated IL can put a warning origin before the first sequence point, which made Last() throw while ILLink flushed cached warnings.

This changes the lookup to tolerate that shape by falling back to the first available sequence point, and adds a focused regression test that round-trips a Cecil-generated assembly/PDB to reproduce the real offset behavior.

This content was created with assistance from AI.

Avoid throwing while formatting diagnostics whose IL offset precedes the first available PDB sequence point. Fall back to the first sequence point and cover the case with a focused MessageContainer test.
Assisted-by: Copilot:gpt-5.5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 20:42
@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jun 25, 2026
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jun 25, 2026

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.

Pull request overview

This PR updates ILLink’s diagnostic origin formatting to handle method IL offsets that occur before the first available PDB sequence point, preventing MessageOrigin.ToString() from throwing when generating MSBuild-formatted messages. It also adds a regression test that constructs and round-trips a Cecil-generated assembly + Portable PDB to reproduce the offset shape.

Changes:

  • Make MessageOrigin.ToString() tolerate "origin before first sequence point" by falling back to the first available sequence point instead of throwing.
  • Add a targeted xUnit regression test that emits a Portable PDB where the only sequence point is after the first IL instruction, then verifies ToMSBuildString() output.
Show a summary per file
File Description
src/tools/illink/src/linker/Linker/MessageOrigin.cs Adjusts sequence point selection logic to avoid Last() throwing when no sequence point exists at/before the IL offset.
src/tools/illink/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs Adds a Cecil-based regression test covering an origin IL offset occurring before the first sequence point.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread src/tools/illink/src/linker/Linker/MessageOrigin.cs Outdated
Keep the existing LINQ-based sequence point lookup but use LastOrDefault so diagnostics whose IL offset precedes the first sequence point fall back to the tool name instead of throwing, matching ILC behavior.
Assisted-by: Copilot:gpt-5.5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

At least 1 approving review is required to merge this pull request.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[area-Tools-ILLink]: Trimmer warnings crash the build

2 participants

AltStyle によって変換されたページ (->オリジナル) /