Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/coreclr/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5687,7 +5687,14 @@ void CheckRegDisplaySP (REGDISPLAY *pRD)
if (pRD->SP && pRD->_pThread)
{
#ifndef NO_FIXED_STACK_LIMIT
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO_FIXED_STACK_LIMIT is working around the same problem, just for Musl. If we find a better way to fix this, we should delete NO_FIXED_STACK_LIMIT.

// Use GetStackLowerBound() instead of GetCachedStackLimit() — on Linux the stack grows on demand
// and the cached limit can be stale if the stack has grown past the initially committed boundary.
// GetStackLowerBound() is only available in non-DAC builds.
#ifndef DACCESS_COMPILE
_ASSERTE(pRD->_pThread->IsExecutingOnAltStack() || PTR_VOID(pRD->SP) >= pRD->_pThread->GetStackLowerBound());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PAL is caching the cache limits as well:

CPalThread::GetCachedStackBase()
{
_ASSERT_MSG(this == InternalGetCurrentThread(), "CPalThread::GetStackBase called from foreign thread");
if (m_stackBase == NULL)
{
m_stackBase = GetStackBase();
}
return m_stackBase;
. This is still going to use cached stack limit as far as I can tell.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will need to pass a bool flag all the way to the PAL to fetch non-cached stack limits.

Also, we make sure to use the cached stack limits most of the time to make this check cheap.

#else
_ASSERTE(pRD->_pThread->IsExecutingOnAltStack() || PTR_VOID(pRD->SP) >= pRD->_pThread->GetCachedStackLimit());
#endif // DACCESS_COMPILE
#endif // NO_FIXED_STACK_LIMIT
_ASSERTE(pRD->_pThread->IsExecutingOnAltStack() || PTR_VOID(pRD->SP) < pRD->_pThread->GetCachedStackBase());
}
Expand Down
Loading