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/9.0] Reduce funceval abort #108256

Merged
merged 2 commits into from
Sep 27, 2024
Merged
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
8 changes: 7 additions & 1 deletion src/coreclr/vm/readytoruninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ void ReadyToRunInfo::SetMethodDescForEntryPointInNativeImage(PCODE entryPoint, M
}
CONTRACTL_END;

// We are entering coop mode here so that we don't do it later inside LookupMap while we are already holding the Crst.
// Doing it in the other order can block the debugger from running func-evals. For example thread A would acquire the Crst,
// then block at the coop transition inside LookupMap waiting for the debugger to resume from a break state. The debugger then
// requests thread B to run a funceval, the funceval tries to load some R2R method calling in here, then it blocks because
// thread A is holding the Crst.
GCX_COOP();
CrstHolder ch(&m_Crst);

if ((TADDR)m_entryPointToMethodDescMap.LookupValue(PCODEToPINSTR(entryPoint), (LPVOID)PCODEToPINSTR(entryPoint)) == (TADDR)INVALIDENTRY)
Expand Down Expand Up @@ -697,7 +703,7 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocat
m_pHeader(pHeader),
m_pNativeImage(pModule != NULL ? pNativeImage: NULL), // m_pNativeImage is only set for composite image components, not the composite R2R info itself
m_readyToRunCodeDisabled(FALSE),
m_Crst(CrstReadyToRunEntryPointToMethodDescMap),
m_Crst(CrstReadyToRunEntryPointToMethodDescMap, CRST_UNSAFE_COOPGC),
m_pPersistentInlineTrackingMap(NULL),
m_pNextR2RForUnrelatedCode(NULL)
{
Expand Down
Loading