m_CacheStackSufficientExecutionLimit = 0;
m_CacheStackStackAllocNonRiskyExecutionLimit = 0;
- m_LastAllowableStackAddress= 0;
- m_ProbeLimit = 0;
-
#ifdef _DEBUG
m_pCleanedStackBase = NULL;
#endif
if (m_CacheStackBase == 0)
{
_ASSERTE(m_CacheStackLimit == 0);
- _ASSERTE(m_LastAllowableStackAddress == 0);
- _ASSERTE(m_ProbeLimit == 0);
ret = SetStackLimits(fAll);
if (ret == FALSE)
{
if (FAILED(CLRSetThreadStackGuarantee()))
return FALSE;
- // Cache the last stack addresses that we are allowed to touch. We throw a stack overflow
- // if we cross that line. Note that we ignore any subsequent calls to STSG for Whidbey until
- // we see an exception and recache the values. We use the LastAllowableAddresses to
- // determine if we've taken a hard SO and the ProbeLimits on the probes themselves.
-
- m_LastAllowableStackAddress = GetLastNormalStackAddress();
-
- if (g_pConfig->ProbeForStackOverflow())
- {
- m_ProbeLimit = m_LastAllowableStackAddress;
- }
- else
- {
- // If we have stack probing disabled, set the probeLimit to 0 so that all probes will pass. This
- // way we don't have to do an extra check in the probe code.
- m_ProbeLimit = 0;
- }
-
return TRUE;
}
}
#endif // _DEBUG
-//
-// IsSPBeyondLimit
-//
-// Determines if the stack pointer is beyond the stack limit, in which case
-// we can assume we've taken a hard SO.
-//
-// Parameters: none
-//
-// Returns: bool indicating if SP is beyond the limit or not
-//
-BOOL Thread::IsSPBeyondLimit()
-{
- WRAPPER_NO_CONTRACT;
-
- // Reset the stack limits if necessary.
- // @todo . Add a vectored handler for X86 so that we reset the stack limits
- // there, as anything that supports SetThreadStackGuarantee will support vectored handlers.
- // Then we can always assume during EH processing that our stack limits are good and we
- // don't have to call ResetStackLimits.
- ResetStackLimits();
- char *approxSP = (char *)GetCurrentSP();
- if (approxSP < (char *)(GetLastAllowableStackAddress()))
- {
- return TRUE;
- }
- return FALSE;
-}
-
NOINLINE void AllocateSomeStack(){
LIMITED_METHOD_CONTRACT;
#ifdef TARGET_X86
static UINT_PTR GetLastNormalStackAddress(UINT_PTR stackBase);
UINT_PTR GetLastNormalStackAddress();
- UINT_PTR GetLastAllowableStackAddress()
- {
- return m_LastAllowableStackAddress;
- }
-
- UINT_PTR GetProbeLimit()
- {
- return m_ProbeLimit;
- }
-
void ResetStackLimits()
{
CONTRACTL
SetStackLimits(fAllowableOnly);
}
- BOOL IsSPBeyondLimit();
-
INDEBUG(static void DebugLogStackMBIs());
#if defined(_DEBUG_IMPL) && !defined(DACCESS_COMPILE)
ThreadExceptionState m_ExceptionState;
- //-----------------------------------------------------------
- // For stack probing. These are the last allowable addresses that a thread
- // can touch. Going beyond is a stack overflow. The ProbeLimit will be
- // set based on whether SO probing is enabled. The LastAllowableAddress
- // will always represent the true stack limit.
- //-----------------------------------------------------------
- UINT_PTR m_ProbeLimit;
-
- UINT_PTR m_LastAllowableStackAddress;
-
private:
//---------------------------------------------------------------
// m_debuggerFilterContext holds the thread's "filter context" for the