Skip to content

Assert handle is not null in HandleToObject#126797

Merged
MichalStrehovsky merged 2 commits intodotnet:mainfrom
MichalPetryka:patch-60
Apr 13, 2026
Merged

Assert handle is not null in HandleToObject#126797
MichalStrehovsky merged 2 commits intodotnet:mainfrom
MichalPetryka:patch-60

Conversation

@MichalPetryka
Copy link
Copy Markdown
Contributor

Add assertion to ensure handle is not null in HandleToObject method.

Beforehand, this resulted in a cryptic IndexOutOfRangeException.

Add assertion to ensure handle is not null in HandleToObject method.

Beforehand, this resulted in a cryptic IndexOutOfRangeException.
Copy link
Copy Markdown
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

The assert that we really need here is not just that the value is not null, but it also has the top bit set. Such assert should be added when #122013 is fixed.

In general the most likely reason to get the IndexOutOfRangeException is the RyuJIT bugs where it treats handle like an integer constant (forgetting it was a handle) and does some math with it. I don't remember seeing null handles. But I guess this doesn't hurt.

@MichalStrehovsky MichalStrehovsky enabled auto-merge (squash) April 12, 2026 23:57
@MichalStrehovsky MichalStrehovsky merged commit fe15cb2 into dotnet:main Apr 13, 2026
107 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants