Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Fix exception when generating warning for method definition - #2972

Merged
vitek-karas merged 1 commit into
dotnet:mainfrom
vitek-karas:FixOriginForMethodDecl
Aug 12, 2022
Merged

vitek-karas merged 1 commit into
dotnet:mainfrom
vitek-karas:FixOriginForMethodDecl

Conversation

@vitek-karas

Copy link
Copy Markdown
Member

If we produce a warning for the method itself (no IL offset) and the method has debug symbols, it can happen that there's no sequence point for the first instruction. In that case the current code will crash because we expect to always find sequence point for offset 0.

Fix this by looking for the first sequence point instead.

Fixes #2971

If we produce a warning for the method itself (no IL offset) and the method has debug symbols, it can happen that there's no sequence point for the first instruction. In that case the current code will crash because we expect to always find sequence point for offset 0.

Fix this by looking for the first sequence point instead.
@vitek-karas

Copy link
Copy Markdown
Member Author

Two additional notes about this:

  1. We basically lack tests which would have symbols for everything and also produce warnings. I didn't try to solve this in this change.
  2. This doesn't repro when linker is launched from VS. For some reason in that case the symbols are read differently and Cecil reports as method not having any sequence points. The exact same thing executed outside of VS works.

@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.

Thanks!

@vitek-karas
vitek-karas merged commit fda7b09 into dotnet:main Aug 12, 2022
@vitek-karas
vitek-karas deleted the FixOriginForMethodDecl branch August 22, 2022 21:50
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…inker#2972)

If we produce a warning for the method itself (no IL offset) and the method has debug symbols, it can happen that there's no sequence point for the first instruction. In that case the current code will crash because we expect to always find sequence point for offset 0.

Fix this by looking for the first sequence point instead.

Commit migrated from dotnet/linker@fda7b09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled exception - System.InvalidOperationException

2 participants