Skip to content
Open
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
15 changes: 15 additions & 0 deletions src/coreclr/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "exinfo.h"
#endif

bool IsCallDescrWorkerInternalReturnAddress(PCODE pCode);

#define HIJACK_NONINTERRUPTIBLE_THREADS

bool ThreadSuspend::s_fSuspendRuntimeInProgress = false;
Expand Down Expand Up @@ -4597,6 +4599,19 @@ void Thread::HijackThread(ExecutionState *esb X86_ARG(ReturnKind returnKind) X86
// Remember the place that the return would have gone
m_pvHJRetAddr = *esb->m_ppvRetAddrPtr;

#ifndef TARGET_X86
// Except for x86, no registers are scanned as part of the HijackFrame on top of the stack.
// This still allows scanning of the return value because the registers in question are
// scanned as part of the calling method's roots. The problem arises if we are returning to
// CallDescrWorkerInternal, which is hand written assembly with no GC info, so a returned
// objectref would be neither reported nor updated by a GC.
if (IsCallDescrWorkerInternalReturnAddress((PCODE)(TADDR)m_pvHJRetAddr))
{
STRESS_LOG2(LF_SYNC, LL_INFO100, "Thread::HijackThread(%p): Early out - return address %p is CallDescrWorkerInternal.\n", this, m_pvHJRetAddr);
return;
}
#endif // !TARGET_X86

IS_VALID_CODE_PTR((FARPROC) (TADDR)m_pvHJRetAddr);
// TODO [DAVBR]: For the full fix for VsWhidbey 450273, the below
// may be uncommented once isLegalManagedCodeCaller works properly
Expand Down
Loading