Skip to content

Commit

Permalink
Split up complicated assert into parts. (dotnet#50620)
Browse files Browse the repository at this point in the history
In an effort to narrow down a hard to repro GCStress issue, the assert
is being split into parts.
  • Loading branch information
AaronRobinsonMSFT authored Apr 2, 2021
1 parent 7d533ab commit fdc3f68
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/coreclr/vm/stackwalk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,9 +1496,9 @@ BOOL StackFrameIterator::IsValid(void)
// In particular, is thread's starting frame the same as it was when
// we started?
BOOL bIsRealStartFrameUnchanged =
(m_pStartFrame != NULL) ||
(m_flags & POPFRAMES) ||
(m_pRealStartFrame == m_pThread->GetFrame());
(m_pStartFrame != NULL)
|| (m_flags & POPFRAMES)
|| (m_pRealStartFrame == m_pThread->GetFrame());

#ifdef FEATURE_HIJACK
// In GCStress >= 4 two threads could race on triggering GC;
Expand All @@ -1508,15 +1508,17 @@ BOOL StackFrameIterator::IsValid(void)
// In normal case (no GCStress), after p/invoke, IL_STUB will check if GC is in progress and synchronize.
// NOTE: This condition needs to be evaluated after the previous one to prevent a subtle race condition
// (https://github.com/dotnet/runtime/issues/11678)
bIsRealStartFrameUnchanged = bIsRealStartFrameUnchanged ||
((GCStress<cfg_instr>::IsEnabled()) &&
(m_pRealStartFrame != NULL) &&
(m_pRealStartFrame != FRAME_TOP) &&
(m_pRealStartFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr()) &&
(m_pThread->GetFrame() != NULL) &&
(m_pThread->GetFrame() != FRAME_TOP) &&
((m_pThread->GetFrame()->GetVTablePtr() == ResumableFrame::GetMethodFrameVPtr()) ||
(m_pThread->GetFrame()->GetVTablePtr() == RedirectedThreadFrame::GetMethodFrameVPtr())));
if (bIsRealStartFrameUnchanged == FALSE)
{
_ASSERTE(GCStress<cfg_instr>::IsEnabled());
_ASSERTE(m_pRealStartFrame != NULL);
_ASSERTE(m_pRealStartFrame != FRAME_TOP);
_ASSERTE(m_pRealStartFrame->GetVTablePtr() == InlinedCallFrame::GetMethodFrameVPtr());
_ASSERTE(m_pThread->GetFrame() != NULL);
_ASSERTE(m_pThread->GetFrame() != FRAME_TOP);
bIsRealStartFrameUnchanged = (m_pThread->GetFrame()->GetVTablePtr() == ResumableFrame::GetMethodFrameVPtr())
|| (m_pThread->GetFrame()->GetVTablePtr() == RedirectedThreadFrame::GetMethodFrameVPtr());
}
#endif // FEATURE_HIJACK

_ASSERTE(bIsRealStartFrameUnchanged);
Expand Down

0 comments on commit fdc3f68

Please sign in to comment.