Skip to content

Commit 0958734

Browse files
committed
[interp][coreclr] Fix virtual generic calls in interpreter
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()) ```
1 parent ffb52e9 commit 0958734

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4071,7 +4071,11 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re
40714071
// intrinsics for the recursive call. Otherwise we will just recurse infinitely and overflow stack.
40724072
// This expansion can produce value that is inconsistent with the value seen by JIT/R2R code that can
40734073
// cause user code to misbehave. This is by design. One-off method Interpretation is for internal use only.
4074-
bool isMustExpand = (callInfo.hMethod == m_methodHnd) || (ni == NI_System_StubHelpers_GetStubContext);
4074+
bool isMustExpand = (callInfo.hMethod == m_methodHnd) || (
4075+
ni == NI_System_StubHelpers_GetStubContext ||
4076+
ni == NI_System_StubHelpers_NextCallReturnAddress ||
4077+
ni == NI_System_Runtime_CompilerServices_RuntimeHelpers_SetNextCallGenericContext ||
4078+
ni == NI_System_Runtime_CompilerServices_RuntimeHelpers_SetNextCallAsyncContinuation);
40754079
if ((InterpConfig.InterpMode() == 3) || isMustExpand)
40764080
{
40774081
if (EmitNamedIntrinsicCall(ni, callInfo.kind == CORINFO_CALL, resolvedCallToken.hClass, callInfo.hMethod, callInfo.sig))

0 commit comments

Comments
 (0)