Skip to content

Delete stackwalk cache #99137

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

Merged
merged 2 commits into from
Mar 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class AsmOffsets

#if TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x8;
public const int SIZEOF__StackFrameIterator = 0x370;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x352;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x368;
public const int SIZEOF__StackFrameIterator = 0x358;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x33A;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x350;
#else // TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
public const int SIZEOF__StackFrameIterator = 0x2d8;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2c2;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2d0;
public const int SIZEOF__StackFrameIterator = 0x2c8;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2b6;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2c4;
#endif // TARGET_64BIT

#else // DEBUG
Expand Down Expand Up @@ -94,14 +94,14 @@ class AsmOffsets

#if TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x8;
public const int SIZEOF__StackFrameIterator = 0x370;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x34a;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x360;
public const int SIZEOF__StackFrameIterator = 0x350;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x332;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x348;
#else // TARGET_64BIT
public const int OFFSETOF__REGDISPLAY__m_pCurrentContext = 0x4;
public const int SIZEOF__StackFrameIterator = 0x2d0;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2ba;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2c8;
public const int SIZEOF__StackFrameIterator = 0x2c0;
public const int OFFSETOF__StackFrameIterator__m_isRuntimeWrappedExceptions = 0x2ae;
public const int OFFSETOF__StackFrameIterator__m_AdjustedControlPC = 0x2bc;
#endif // TARGET_64BIT

#endif // DEBUG
Expand Down Expand Up @@ -155,7 +155,7 @@ class AsmOffsets
public const int OFFSETOF__ExInfo__m_kind = 0xd0;
public const int OFFSETOF__ExInfo__m_passNumber = 0xd1;
public const int OFFSETOF__ExInfo__m_idxCurClause = 0xd4;
public const int OFFSETOF__ExInfo__m_frameIter = 0xe0;
public const int OFFSETOF__ExInfo__m_frameIter = 0xd8;
public const int OFFSETOF__ExInfo__m_notifyDebuggerSP = OFFSETOF__ExInfo__m_frameIter + SIZEOF__StackFrameIterator;
#else // TARGET_64BIT
public const int SIZEOF__EHEnum = 0x10;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/classlibnative/bcltype/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void SystemNative::GenericFailFast(STRINGREF refMesgString, EXCEPTIONREF refExce
FindFailFastCallerStruct findCallerData;
findCallerData.pStackMark = stackMark;
findCallerData.retAddress = 0;
StackWalkFunctions(GetThread(), FindFailFastCallerCallback, &findCallerData);
GetThread()->StackWalkFrames(FindFailFastCallerCallback, &findCallerData, FUNCTIONSONLY | QUICKUNWIND);

// Managed code injected FailFast maps onto the unmanaged version
// (EEPolicy::HandleFatalError) in the following manner: the exit code is
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/inc/CrstTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ Crst PendingTypeLoadEntry
DomainLocalBlock Exception ExecuteManRangeLock FuncPtrStubs
FusionAppCtx GlobalStrLiteralMap HandleTable IbcProfile
IJWFixupData IJWHash ISymUnmanagedReader Jit JumpStubCache LoaderHeap
Module ModuleLookupTable PEImage SecurityStackwalkCache
Module ModuleLookupTable PEImage
SigConvert SingleUseLock StubDispatchCache StubUnwindInfoHeapSegments
SyncBlockCache SystemDomain ThreadIdDispenser ThreadStore TypeIDMap UnresolvedClassLock
SameLevelAs PendingTypeLoadEntry
Expand Down Expand Up @@ -426,9 +426,6 @@ End
Crst SaveModuleProfileData
End

Crst SecurityStackwalkCache
End

Crst SigConvert
AcquiredBefore LoaderHeap
End
Expand Down
57 changes: 27 additions & 30 deletions src/coreclr/inc/crsttypes_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,33 @@ enum CrstType
CrstRetThunkCache = 89,
CrstSavedExceptionInfo = 90,
CrstSaveModuleProfileData = 91,
CrstSecurityStackwalkCache = 92,
CrstSigConvert = 93,
CrstSingleUseLock = 94,
CrstSpecialStatics = 95,
CrstStackSampler = 96,
CrstStaticBoxInit = 97,
CrstStressLog = 98,
CrstStubCache = 99,
CrstStubDispatchCache = 100,
CrstStubUnwindInfoHeapSegments = 101,
CrstSyncBlockCache = 102,
CrstSyncHashLock = 103,
CrstSystemBaseDomain = 104,
CrstSystemDomain = 105,
CrstSystemDomainDelayedUnloadList = 106,
CrstThreadIdDispenser = 107,
CrstThreadStore = 108,
CrstTieredCompilation = 109,
CrstTypeEquivalenceMap = 110,
CrstTypeIDMap = 111,
CrstUMEntryThunkCache = 112,
CrstUMEntryThunkFreeListLock = 113,
CrstUniqueStack = 114,
CrstUnresolvedClassLock = 115,
CrstUnwindInfoTableLock = 116,
CrstVSDIndirectionCellLock = 117,
CrstWrapperTemplate = 118,
kNumberOfCrstTypes = 119
CrstSigConvert = 92,
CrstSingleUseLock = 93,
CrstSpecialStatics = 94,
CrstStackSampler = 95,
CrstStaticBoxInit = 96,
CrstStressLog = 97,
CrstStubCache = 98,
CrstStubDispatchCache = 99,
CrstStubUnwindInfoHeapSegments = 100,
CrstSyncBlockCache = 101,
CrstSyncHashLock = 102,
CrstSystemBaseDomain = 103,
CrstSystemDomain = 104,
CrstSystemDomainDelayedUnloadList = 105,
CrstThreadIdDispenser = 106,
CrstThreadStore = 107,
CrstTieredCompilation = 108,
CrstTypeEquivalenceMap = 109,
CrstTypeIDMap = 110,
CrstUMEntryThunkCache = 111,
CrstUMEntryThunkFreeListLock = 112,
CrstUniqueStack = 113,
CrstUnresolvedClassLock = 114,
CrstUnwindInfoTableLock = 115,
CrstVSDIndirectionCellLock = 116,
CrstWrapperTemplate = 117,
kNumberOfCrstTypes = 118
};

#endif // __CRST_TYPES_INCLUDED
Expand Down Expand Up @@ -237,7 +236,6 @@ int g_rgCrstLevelMap[] =
4, // CrstRetThunkCache
3, // CrstSavedExceptionInfo
0, // CrstSaveModuleProfileData
0, // CrstSecurityStackwalkCache
4, // CrstSigConvert
5, // CrstSingleUseLock
0, // CrstSpecialStatics
Expand Down Expand Up @@ -361,7 +359,6 @@ LPCSTR g_rgCrstNameMap[] =
"CrstRetThunkCache",
"CrstSavedExceptionInfo",
"CrstSaveModuleProfileData",
"CrstSecurityStackwalkCache",
"CrstSigConvert",
"CrstSingleUseLock",
"CrstSpecialStatics",
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ DEFINE_DACVAR(PTR_SString, SString__s_Empty, SString::s_Empty)

DEFINE_DACVAR(INT32, ArrayBase__s_arrayBoundsZero, ArrayBase::s_arrayBoundsZero)

DEFINE_DACVAR(BOOL, StackwalkCache__s_Enabled, StackwalkCache::s_Enabled)

DEFINE_DACVAR(PTR_JITNotification, dac__g_pNotificationTable, ::g_pNotificationTable)
DEFINE_DACVAR(ULONG32, dac__g_dacNotificationFlags, ::g_dacNotificationFlags)
DEFINE_DACVAR(PTR_GcNotification, dac__g_pGcNotificationTable, ::g_pGcNotificationTable)
Expand Down
29 changes: 14 additions & 15 deletions src/coreclr/inc/eetwain.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#define USE_GC_INFO_DECODER
#endif

#if (defined(TARGET_X86) && !defined(TARGET_UNIX)) || defined(TARGET_AMD64)
#define HAS_QUICKUNWIND
#ifdef TARGET_AMD64
#define HAS_LIGHTUNWIND
#endif

#define CHECK_APP_DOMAIN 0
Expand Down Expand Up @@ -103,6 +103,8 @@ enum ICodeManagerFlags
NoReportUntracked
= 0x0080, // EnumGCRefs/EnumerateLiveSlots should *not* include
// any untracked slots

LightUnwind = 0x0100, // Unwind just enough to get return addresses
};

//*****************************************************************************
Expand Down Expand Up @@ -201,8 +203,7 @@ virtual ULONG32 GetStackParameterSize(EECodeInfo* pCodeInfo) = 0;
virtual bool UnwindStackFrame(PREGDISPLAY pContext,
EECodeInfo *pCodeInfo,
unsigned flags,
CodeManState *pState,
StackwalkCacheUnwindInfo *pUnwindInfo) = 0;
CodeManState *pState) = 0;

/*
Is the function currently at a "GC safe point" ?
Expand Down Expand Up @@ -425,11 +426,10 @@ bool UnwindStackFrame(
PREGDISPLAY pContext,
EECodeInfo *pCodeInfo,
unsigned flags,
CodeManState *pState,
StackwalkCacheUnwindInfo *pUnwindInfo);
CodeManState *pState);

#ifdef HAS_QUICKUNWIND
enum QuickUnwindFlag
#ifdef HAS_LIGHTUNWIND
enum LightUnwindFlag
{
UnwindCurrentStackFrame,
EnsureCallerStackFrameIsValid
Expand All @@ -441,11 +441,11 @@ enum QuickUnwindFlag
*/

static
void QuickUnwindStackFrame(
void LightUnwindStackFrame(
PREGDISPLAY pRD,
StackwalkCacheEntry *pCacheEntry,
QuickUnwindFlag flag);
#endif // HAS_QUICKUNWIND
EECodeInfo *pCodeInfo,
LightUnwindFlag flag);
#endif // HAS_LIGHTUNWIND

/*
Is the function currently at a "GC safe point" ?
Expand Down Expand Up @@ -615,7 +615,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
#endif // #ifndef DACCESS_COMPILE

#ifdef FEATURE_EH_FUNCLETS
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, StackwalkCacheEntry* pCacheEntry, EECodeInfo * pCodeInfo = NULL );
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, EECodeInfo * pCodeInfo = NULL, unsigned flags = 0);
static size_t GetCallerSp( PREGDISPLAY pRD );
#ifdef TARGET_X86
static size_t GetResumeSp( PCONTEXT pContext );
Expand All @@ -632,8 +632,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,
bool UnwindStackFrame(PREGDISPLAY pContext,
EECodeInfo *pCodeInfo,
unsigned flags,
CodeManState *pState,
StackwalkCacheUnwindInfo *pUnwindInfo);
CodeManState *pState);

size_t DecodeGCHdrInfo(GCInfoToken gcInfoToken,
unsigned curOffset,
Expand Down
18 changes: 11 additions & 7 deletions src/coreclr/inc/regdisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ inline void FillContextPointers(PT_KNONVOLATILE_CONTEXT_POINTERS pCtxPtrs, PT_CO
}
#endif // FEATURE_EH_FUNCLETS

inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pCallerCtx = NULL)
inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pCallerCtx = NULL, bool fLightUnwind = false)
{
WRAPPER_NO_CONTRACT;

Expand Down Expand Up @@ -497,6 +497,16 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
pRD->IsCallerSPValid = TRUE; // Don't add usage of this field. This is only temporary.
}

#ifdef DEBUG_REGDISPLAY
pRD->_pThread = NULL;
#endif // DEBUG_REGDISPLAY

// This will setup the PC and SP
SyncRegDisplayToCurrentContext(pRD);

if (fLightUnwind)
return;

FillContextPointers(&pRD->ctxPtrsOne, pctx);

#if defined(TARGET_ARM)
Expand Down Expand Up @@ -550,12 +560,6 @@ inline void FillRegDisplay(const PREGDISPLAY pRD, PT_CONTEXT pctx, PT_CONTEXT pC
pRD->volatileCurrContextPointers.T6 = &pctx->T6;
#endif // TARGET_RISCV64

#ifdef DEBUG_REGDISPLAY
pRD->_pThread = NULL;
#endif // DEBUG_REGDISPLAY

// This will setup the PC and SP
SyncRegDisplayToCurrentContext(pRD);
#endif // !FEATURE_EH_FUNCLETS
}

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/unwinder/i386/unwinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BOOL OOPStackUnwinderX86::Unwind(T_CONTEXT* pContextRecord, T_KNONVOLATILE_CONTE
EECodeInfo codeInfo;
codeInfo.Init((PCODE) ControlPc);

if (!UnwindStackFrame(&rd, &codeInfo, UpdateAllRegs, &codeManState, NULL))
if (!UnwindStackFrame(&rd, &codeInfo, UpdateAllRegs, &codeManState))
{
return FALSE;
}
Expand Down
12 changes: 0 additions & 12 deletions src/coreclr/vm/amd64/AsmHelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -634,18 +634,6 @@ NESTED_ENTRY ProfileTailcallNaked, _TEXT
NESTED_END ProfileTailcallNaked, _TEXT


; EXTERN_C void moveOWord(LPVOID* src, LPVOID* target);
; <NOTE>
; MOVDQA is not an atomic operation. You need to call this function in a crst.
; </NOTE>
LEAF_ENTRY moveOWord, _TEXT
movdqa xmm0, [rcx]
movdqa [rdx], xmm0

ret
LEAF_END moveOWord, _TEXT


extern JIT_InternalThrowFromHelper:proc

LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT
Expand Down
11 changes: 0 additions & 11 deletions src/coreclr/vm/amd64/unixasmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler
TAILJMP_RAX
NESTED_END NDirectImportThunk, _TEXT

// EXTERN_C void moveOWord(LPVOID* src, LPVOID* target);
// <NOTE>
// MOVDQA is not an atomic operation. You need to call this function in a crst.
// </NOTE>
LEAF_ENTRY moveOWord, _TEXT
movdqu xmm0, xmmword ptr [rdi]
movdqu xmmword ptr [rsi], xmm0

ret
LEAF_END moveOWord, _TEXT

//------------------------------------------------
// JIT_RareDisableHelper
//
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,6 @@ void EEStartupHelper()
// Set up the sync block
SyncBlockCache::Start();

StackwalkCache::Init();

// This isn't done as part of InitializeGarbageCollector() above because it
// requires write barriers to have been set up on x86, which happens as part
// of InitJITHelpers1.
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4938,14 +4938,6 @@ void ExecutionManager::Unload(LoaderAllocator *pLoaderAllocator)
// a size of 0 is a signal to Nirvana to flush the entire cache
FlushInstructionCache(GetCurrentProcess(),0,0);

/* StackwalkCacheEntry::EIP is an address into code. Since we are
unloading the code, we need to invalidate the cache. Otherwise,
its possible that another appdomain might generate code at the very
same address, and we might incorrectly think that the old
StackwalkCacheEntry corresponds to it. So flush the cache.
*/
StackwalkCache::Invalidate(pLoaderAllocator);

JumpStubCache * pJumpStubCache = (JumpStubCache *) pLoaderAllocator->m_pJumpStubCache;
if (pJumpStubCache != NULL)
{
Expand Down
Loading