Skip to content

[release/10.0] Fix off-by-one error in TypePreinit switch instruction handling#127587

Merged
agocke merged 1 commit into
release/10.0from
backport/pr-123911-to-release/10.0
May 7, 2026
Merged

[release/10.0] Fix off-by-one error in TypePreinit switch instruction handling#127587
agocke merged 1 commit into
release/10.0from
backport/pr-123911-to-release/10.0

Conversation

@github-actions

@github-actions github-actions Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Backport of #123911 to release/10.0

/cc @agocke @sbomer

Customer Impact

  • Customer reported
  • Found internally

When the value exactly equals the case count, the code tried to read a non-existent jump table entry, corrupting the IL reader offset and causing an IndexOutOfRangeException during NativeAOT compilation.

Regression

  • Yes
  • No

Testing

Unit tests

Risk

Low

)

The switch IL instruction interpreter used > instead of >= when checking
if the switch value exceeds the case count. Per ECMA-335, switch should
fall through to the next instruction when value >= count, but the code
only did this for value > count.

When value exactly equals count, the code tried to read a non-existent
jump table entry, corrupting the IL reader offset and causing an
IndexOutOfRangeException during NativeAOT compilation.

Added test case for the boundary condition (value == case count).
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@agocke

agocke commented May 7, 2026

Copy link
Copy Markdown
Member

/ba-g failures are unrelated

@agocke agocke merged commit 5968a6f into release/10.0 May 7, 2026
105 of 112 checks passed
@agocke agocke deleted the backport/pr-123911-to-release/10.0 branch May 7, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants