Skip to content

Conversation

@davidwrighton
Copy link
Member

When a try block exactly encloses another try/finally or try/catch block and the handler ends at the same point the try body ends we had an off by one issue in our reprentation of the ilOffset on the leave chain islands. This fixes the off by one issue for that kind of basic block. The C# compiler seems to always inject a nop to avoid this issue, but I do not know why and I can find no justification for that rule.

Fixes badcodeinsidefinally tests

When a try block exactly encloses another try/finally or try/catch block and the handler ends at the same point the try body ends we had an off by one issue in our reprentation of the ilOffset on the leave chain islands. This fixes the off by one issue for that kind of basic block. The C# compiler seems to always inject a nop to avoid this issue, but I do not know why and I can find no justification for that rule.

Fixes badcodeinsidefinally tests
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

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 fixes an off-by-one issue in the CLR interpreter's exception handling (EH) logic for leave chain islands. The issue occurs when a try block exactly encloses another try/finally or try/catch block and the handler ends at the same point the try body ends.

Key changes:

  • Added isLeaveChainIsland field to InterpBasicBlock to identify leave chain island basic blocks
  • Updated EH clause overlap counting logic to skip leave chain islands that coincide with handler/filter boundaries
  • Modified GetNativeRangeForClause to include leave chain islands at clause boundaries when determining native ranges

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/coreclr/interpreter/compiler.h Added new isLeaveChainIsland boolean field to InterpBasicBlock struct and initialized it in the constructor
src/coreclr/interpreter/compiler.cpp Updated EH clause overlap logic to handle leave chain islands at boundaries, modified native range calculation to include boundary leave chain islands, added debug logging, and set the new flag during leave chain island creation

@davidwrighton
Copy link
Member Author

/azp run runtime-interpreter

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants