From 54c8d6d048d2203119113dc4030cedc322ca212c Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 16 Sep 2025 10:57:35 -0700 Subject: [PATCH] Suppress tailcall flag if target is a non-marshaled pinvoke (tail calling a marshaled pinvoke should work since the stub is IL) --- src/coreclr/interpreter/compiler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/interpreter/compiler.cpp b/src/coreclr/interpreter/compiler.cpp index a6ca51b83b0984..cf9a1e04385121 100644 --- a/src/coreclr/interpreter/compiler.cpp +++ b/src/coreclr/interpreter/compiler.cpp @@ -3551,6 +3551,10 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re } else { + // Tail call target needs to be IL + if (tailcall && isPInvoke && !isMarshaledPInvoke) + tailcall = false; + // Normal call InterpOpcode opcode; if (isDelegateInvoke) @@ -3560,7 +3564,6 @@ void InterpCompiler::EmitCall(CORINFO_RESOLVED_TOKEN* pConstrainedToken, bool re } else if (tailcall) { - assert(!isPInvoke && !isMarshaledPInvoke); opcode = INTOP_CALL_TAIL; } else