[interp][coreclr] Fix virtual generic calls in interpreter#122069
Merged
radekdoulik merged 1 commit intodotnet:mainfrom Dec 1, 2025
Merged
[interp][coreclr] Fix virtual generic calls in interpreter#122069radekdoulik merged 1 commit intodotnet:mainfrom
radekdoulik merged 1 commit intodotnet:mainfrom
Conversation
Fix regression introduced in dotnet#121799 Force intrinsic expansion for new runtime helpers in the interpreter. Added the new methods and also NI_System_StubHelpers_NextCallReturnAddress, which has also `// Unconditionally expanded intrinsic` comment. This was happening on wasm and possibly on other platforms too, resulting in unhandled exception. Possibly only happening on platforms using generic instantiation IL stubs. ``` Unhandled exception. System.Diagnostics.UnreachableException: The program executed an instruction that was thought to be unreachable. at System.Runtime.CompilerServices.RuntimeHelpers.SetNextCallGenericContext(Void* value) in /Users/rodo/git/runtime-clean/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs:line 186 at InterpreterTest.TestVirtual() in /Users/rodo/git/runtime-clean/src/tests/JIT/interpreter/Interpreter.cs:line 1960 at InterpreterTest.RunInterpreterTests() in /Users/rodo/git/runtime-clean/src/tests/JIT/interpreter/Interpreter.cs:line 896 at InterpreterTest.Main(String[] args) in /Users/rodo/git/runtime-clean/src/tests/JIT/interpreter/Interpreter.cs:line 731 Aborted(native code called abort()) ```
Member
Author
|
I wonder if we can find better way to detect these. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in the interpreter where virtual generic calls were causing unhandled exceptions due to certain runtime helper intrinsics not being expanded. The fix ensures that intrinsics marked as "Unconditionally expanded" are always processed by the interpreter's intrinsic expansion logic.
Key Changes
- Added four runtime helper intrinsics to the
isMustExpandcondition in the interpreter's call emission code - These intrinsics must be unconditionally expanded to prevent infinite recursion and stack overflow
- The fix specifically addresses virtual generic method calls that were failing on WebAssembly and potentially other platforms using generic instantiation IL stubs
jkotas
reviewed
Dec 1, 2025
jkotas
approved these changes
Dec 1, 2025
This was referenced Dec 1, 2025
Open
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.
Fix regression introduced in #121799
Force intrinsic expansion for new runtime helpers in the interpreter.
Added the new methods and also
NI_System_StubHelpers_NextCallReturnAddress, which has also// Unconditionally expanded intrinsiccomment.This was happening on wasm and possibly on other platforms too, resulting in unhandled exception. Possibly only on platforms, which use generic instantiation IL stubs.