diff --git a/src/coreclr/vm/reflectioninvocation.cpp b/src/coreclr/vm/reflectioninvocation.cpp index fa76344e9274c6..85d8ba33f420d4 100644 --- a/src/coreclr/vm/reflectioninvocation.cpp +++ b/src/coreclr/vm/reflectioninvocation.cpp @@ -25,6 +25,8 @@ #include "dbginterface.h" #include "argdestination.h" +#include "interpexec.h" + extern "C" void QCALLTYPE RuntimeFieldHandle_GetValue(FieldDesc* fieldDesc, QCall::ObjectHandleOnStack instance, QCall::TypeHandle fieldType, QCall::TypeHandle declaringType, BOOL* pIsClassInitialized, QCall::ObjectHandleOnStack result) { QCALL_CONTRACT; @@ -1362,6 +1364,23 @@ FCIMPL0(FC_BOOL_RET, ReflectionInvocation::TryEnsureSufficientExecutionStack) UINT_PTR current = reinterpret_cast(&pThread); UINT_PTR limit = pThread->GetCachedStackSufficientExecutionLimit(); +#ifdef FEATURE_INTERPRETER + InterpThreadContext* pInterpThreadContext = pThread->GetInterpThreadContext(); + if (pInterpThreadContext != nullptr) + { + // The interpreter has its own stack, so we need to check against that too. +#ifdef HOST_64BIT + const UINT_PTR MinExecutionStackSize = 128 * 1024; +#else // !HOST_64BIT + const UINT_PTR MinExecutionStackSize = 64 * 1024; +#endif // HOST_64BIT + if (pInterpThreadContext->pStackPointer >= pInterpThreadContext->pStackEnd - MinExecutionStackSize) + { + FC_RETURN_BOOL(FALSE); + } + } +#endif // FEATURE_INTERPRETER + FC_RETURN_BOOL(current >= limit); } FCIMPLEND