Skip to content

CodeQL ilasm fixes#125152

Merged
dhartglassMSFT merged 9 commits intodotnet:mainfrom
dhartglassMSFT:ilasm_codeQL1
Mar 16, 2026
Merged

CodeQL ilasm fixes#125152
dhartglassMSFT merged 9 commits intodotnet:mainfrom
dhartglassMSFT:ilasm_codeQL1

Conversation

@dhartglassMSFT
Copy link
Contributor

@dhartglassMSFT dhartglassMSFT commented Mar 3, 2026

Fix two issues that got flagged

1 - Fix a mistyped loop counter.

2 - One of the files frequently casts CHAR*->WCHAR*. Retyping isn't reasonable, because these methods are called through function pointers using char*. These casts are probably safe since they all point into MapViewOfFile, but I add alignment constraints and bailouts if somehow we have an odd pointer. The analyzer still complains however, so I also need an explicit suppression of the warning.

I'm kicking off another analysis pipeline in a bit to make sure the suppressions get picked up

Copilot AI review requested due to automatic review settings March 3, 2026 23:10
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib
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 targets CodeQL/static-analysis findings in the CoreCLR ilasm tool by addressing integer type correctness and potential unaligned UTF-16 access patterns in the parser/helpers.

Changes:

  • Use an unsigned 16-bit loop index when iterating metadata streams during PE file creation.
  • Avoid unaligned WCHAR* dereferences in SymW by reading via memcpy.
  • Add/adjust alignment handling for Unicode parsing helpers (aligned buffers; enforce even-byte lengths for UTF-16 token copies).

Reviewed changes

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

File Description
src/coreclr/ilasm/writer.cpp Updates stream-iteration index type to avoid signed/size issues when walking metadata streams.
src/coreclr/ilasm/grammar_after.cpp Hardens Unicode parsing helpers against unaligned access and odd-length UTF-16 token handling (plus aligned scratch buffers).

@dhartglassMSFT dhartglassMSFT marked this pull request as ready for review March 4, 2026 22:21
Copilot AI review requested due to automatic review settings March 4, 2026 22:21
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 2 comments.

@dhartglassMSFT dhartglassMSFT changed the title [Draft] CodeQL ilasm fixes CodeQL ilasm fixes Mar 4, 2026
Copilot AI review requested due to automatic review settings March 4, 2026 22:29
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 3 comments.

Copilot AI review requested due to automatic review settings March 5, 2026 00:53
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.

@am11
Copy link
Member

am11 commented Mar 5, 2026

I think focus should move to the managed ilasm in src/tools/ilasm, which will eventually make the native implementation obsolete.

@AaronRobinsonMSFT
Copy link
Member

I think focus should move to the managed ilasm in src/tools/ilasm, which will eventually make the native implementation obsolete.

Until that is working, which is a long ways off, we still need to satisfy tooling and all the requirements for the existing code.

@am11
Copy link
Member

am11 commented Mar 5, 2026

which is a long ways off,

It is just pending test infra support, everything else is in place; all TODOs addressed.

Copilot AI review requested due to automatic review settings March 9, 2026 20:26
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 3 out of 3 changed files in this pull request and generated 2 comments.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

:shipit:

Copilot AI review requested due to automatic review settings March 10, 2026 21:00
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 3 out of 3 changed files in this pull request and generated 3 comments.

@dhartglassMSFT dhartglassMSFT enabled auto-merge (squash) March 10, 2026 21:18
@dhartglassMSFT dhartglassMSFT merged commit 611b2cb into dotnet:main Mar 16, 2026
127 checks passed
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.

4 participants