Fix passing class handle to RuntimeTypeHandle.GetRuntimeTypeFromHandle for synchronized methods#117675
Merged
elinor-fung merged 5 commits intodotnet:mainfrom Jul 16, 2025
Merged
Conversation
…le for synchronized methods - use method class handle
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where synchronized methods in collectible assemblies were passing an invalid handle to RuntimeTypeHandle.GetRuntimeTypeFromHandle, causing NullReferenceException. The fix simplifies the code by removing the getMethodSync JIT interface method and directly using the class handle instead.
- Removes the
getMethodSyncmethod from the JIT interface, which was only used for synchronized methods - Changes the JIT code generation to directly use the method's class handle with
CORINFO_HELP_GETSYNCFROMCLASSHANDLE - Adds a regression test to verify synchronized methods work correctly in collectible assembly load contexts
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/flowgraph.cpp | Updated code generation to use class handle directly instead of calling getMethodSync |
| src/coreclr/inc/corinfo.h | Removed getMethodSync method declaration from ICorDynamicInfo interface |
| src/coreclr/vm/jitinterface.h | Removed getMethodSync method declaration from CEECodeGenInfo class |
| src/coreclr/vm/jitinterface.cpp | Removed getMethodSync implementation and GetClassSync helper function |
| src/coreclr/inc/jiteeversionguid.h | Updated JIT-EE interface version GUID due to interface change |
| src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.cs | Added regression test for synchronized methods in collectible assemblies |
| src/tests/JIT/Regression/JitBlue/Runtime_117566/Runtime_117566.csproj | Test project configuration |
| Multiple generated files | Updated to remove getMethodSync from various JIT interface implementations |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
jkotas
reviewed
Jul 15, 2025
jkotas
approved these changes
Jul 15, 2025
….csproj Co-authored-by: Jan Kotas <[email protected]>
AndyAyersMS
approved these changes
Jul 16, 2025
This was referenced Jul 16, 2025
Open
Member
Author
|
/ba-g timeout: #117669 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After #107667, synchronized methods in collectible assemblies were passing an invalid handle as the class handle to
RuntimeTypeHandle.GetRuntimeTypeFromHandle(callingCORINFO_HELP_GETSYNCFROMCLASSHANDLE).getMethodSyncfrom JIT interface - it was only used in this one place where we actually need the class handleResolves #117566
cc @dotnet/jit-contrib @jkotas @janvorli @davidwrighton