From 9fcc15fb4208fa672f269344df558506f0191304 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sun, 1 Jul 2018 06:02:04 -0700 Subject: [PATCH] Fix recursive inlining of PInvoke stubs (dotnet/coreclr#18737) PInvoke stubs can be inlined into a regular methods in CoreRT. PInvoke transition has to be inlined as well when that happens. Otherwise, there is a risk of recursive inlining in corner cases. Commit migrated from https://github.com/dotnet/coreclr/commit/55023b7c1007c528b0147fe839cea5ac4a100e2f --- src/coreclr/src/jit/importer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/jit/importer.cpp b/src/coreclr/src/jit/importer.cpp index 8ec9303..6f6bd21 100644 --- a/src/coreclr/src/jit/importer.cpp +++ b/src/coreclr/src/jit/importer.cpp @@ -6112,9 +6112,9 @@ void Compiler::impCheckForPInvokeCall( return; } - // PInvoke CALL in IL stubs must be inlined on CoreRT. Skip the ambient conditions checks and - // profitability checks - if (!(opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && IsTargetAbi(CORINFO_CORERT_ABI))) + // Legal PInvoke CALL in PInvoke IL stubs must be inlined to avoid infinite recursive + // inlining in CoreRT. Skip the ambient conditions checks and profitability checks. + if (!IsTargetAbi(CORINFO_CORERT_ABI) || (info.compFlags & CORINFO_FLG_PINVOKE) == 0) { if (!impCanPInvokeInline()) { -- 2.7.4