Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/8.0] Fix stack_limit handling #91095

Merged
merged 4 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 15 additions & 3 deletions src/coreclr/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,28 @@ static void ScanStackRoots(Thread * pThread, promote_func* fn, ScanContext* sc)
IsGCSpecialThread() ||
(GetThread() == ThreadSuspend::GetSuspensionThread() && ThreadStore::HoldingThreadStore()));

#if defined(FEATURE_CONSERVATIVE_GC) || defined(USE_FEF)
Frame* pTopFrame = pThread->GetFrame();
Object ** topStack = (Object **)pTopFrame;
if ((pTopFrame != ((Frame*)-1))
&& (pTopFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr())) {
// It is an InlinedCallFrame. Get SP from it.
if (InlinedCallFrame::FrameHasActiveCall(pTopFrame))
{
// It is an InlinedCallFrame with active call. Get SP from it.
InlinedCallFrame* pInlinedFrame = (InlinedCallFrame*)pTopFrame;
topStack = (Object **)pInlinedFrame->GetCallSiteSP();
}
#endif // FEATURE_CONSERVATIVE_GC || USE_FEF

#ifdef USE_FEF
// We only set the stack_limit when FEF (FaultingExceptionFrame) is enabled, because without the
// FEF, the code above would have to check if hardware exception is being handled and get the limit
// from the exception frame. Since the stack_limit is strictly necessary only on Unix and FEF is
// not enabled on Window x86 only, it is sufficient to keep the stack_limit set to 0 in this case.
// See the comment on the stack_limit usage in the PromoteCarefully function for more details.
sc->stack_limit = (uintptr_t)topStack;
#else // USE_FEF
// It should be set to 0 in the ScanContext constructor
_ASSERTE(sc->stack_limit == 0);
#endif // USE_FEF

#ifdef FEATURE_CONSERVATIVE_GC
if (g_pConfig->GetGCConservative())
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/vm/siginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4962,11 +4962,6 @@ void PromoteCarefully(promote_func fn,

#if !defined(DACCESS_COMPILE)

//
// Sanity check the stack scan limit
//
assert(sc->stack_limit != 0);

// Note that the base is at a higher address than the limit, since the stack
// grows downwards.
// To check whether the object is in the stack or not, we also need to check the sc->stack_limit.
Expand Down
Loading