Skip to content

Conversation

elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Jul 15, 2025

After #107667, synchronized methods in collectible assemblies were passing an invalid handle as the class handle to RuntimeTypeHandle.GetRuntimeTypeFromHandle (calling CORINFO_HELP_GETSYNCFROMCLASSHANDLE).

  • Fix the generated code to actually pass the method's class handle.
  • Remove getMethodSync from JIT interface - it was only used in this one place where we actually need the class handle
  • Add regression test

Resolves #117566

cc @dotnet/jit-contrib @jkotas @janvorli @davidwrighton

@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 18:13
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 15, 2025
Copy link
Contributor

@Copilot 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 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 getMethodSync method 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

@elinor-fung elinor-fung requested a review from a team July 15, 2025 18:14
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@elinor-fung elinor-fung added this to the 10.0.0 milestone Jul 15, 2025
@elinor-fung
Copy link
Member Author

/ba-g timeout: #117669

@elinor-fung elinor-fung merged commit 63e797e into dotnet:main Jul 16, 2025
105 of 107 checks passed
@elinor-fung elinor-fung deleted the fix117566 branch July 16, 2025 17:13
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid handle passed to RuntimeTypeHandle.GetRuntimeTypeFromHandle when calling a synchronized method in a collectible assembly in .NET 10

3 participants