Skip to content

Improve zero-sized methods check and missing ret at exit - #112082

Closed
kant2002 wants to merge 2 commits into
dotnet:mainfrom
kant2002:kant/iron-zerosize-method
Closed

kant2002 wants to merge 2 commits into
dotnet:mainfrom
kant2002:kant/iron-zerosize-method

Conversation

@kant2002

@kant2002 kant2002 commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

Closes #63227

@ghost ghost added the area-ReadyToRun label Feb 3, 2025
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Feb 3, 2025
Comment on lines +218 to +219
if ((uint)_currentOffset < (uint)_basicBlocks.Length)
CreateBasicBlock(_currentOffset);

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.

Do we need a check like this for the other cases in this method (e.g. the non-_s variant of these instructions)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

and in switch too.

Comment on lines +459 to +463
if (_currentOffset < _basicBlocks.Length && _currentOffset + delta < _basicBlocks.Length)
{
ImportBranch(opCode + (ILOpcode.br - ILOpcode.br_s),
_basicBlocks[_currentOffset + delta], (opCode != ILOpcode.br_s) ? _basicBlocks[_currentOffset] : null);
}

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.

Would the new if check ever be false given we'd abort for this in FindJumpTargets already?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't abort at ReportFallthroughAtEndOfMethod. At least that was the one case of usage case, and I do not know the codebase that well to think about is this abort is reasonable way to handle.

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.

We may want to abort at ReportFallthroughAtEndOfMethod to keep things simple.

int delta = (sbyte)ReadILByte();
ImportBranch(opCode + (ILOpcode.br - ILOpcode.br_s),
_basicBlocks[_currentOffset + delta], (opCode != ILOpcode.br_s) ? _basicBlocks[_currentOffset] : null);
if (_currentOffset < _basicBlocks.Length && _currentOffset + delta < _basicBlocks.Length)

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.

It does not look right to ignore the invalid code silently.

if ((uint)_currentOffset < (uint)_basicBlocks.Length)
CreateBasicBlock(_currentOffset);
else
{

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.

Formatting: If one side of if-else has curly braces, the other side should have them too.

@JulieLeeMSFT

Copy link
Copy Markdown
Member

@kant2002, just checking if you plan to get back to this PR anytime soon.

@JulieLeeMSFT JulieLeeMSFT added the needs-author-action An issue or pull request that requires more info or actions from the author. label Mar 3, 2025
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked no-recent-activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no-recent-activity.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

This pull request will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the pull request, but please note that it will be locked if it remains inactive for another 30 days.

@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILVerification Issues related to ilverify tool and IL verification in general community-contribution Indicates that the PR has been added by a community member needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad data can cause ILVerify to throw IndexOutOfRangeException

4 participants