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

Fix to allow entering cooperative GC mode when the thread is in a forbid-suspend-for-debugger region #42587

Merged
merged 1 commit into from
Sep 23, 2020
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: 5 additions & 3 deletions src/coreclr/src/vm/threadsuspend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2269,8 +2269,9 @@ void Thread::RareDisablePreemptiveGC()
// Note IsGCInProgress is also true for say Pause (anywhere SuspendEE happens) and GCThread is the
// thread that did the Pause. While in Pause if another thread attempts Rev/Pinvoke it should get inside the following and
// block until resume
if ((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
(m_State & (TS_DebugSuspendPending | TS_StackCrawlNeeded)))
if ((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
((m_State & TS_DebugSuspendPending) && !IsInForbidSuspendForDebuggerRegion()) ||
(m_State & TS_StackCrawlNeeded))
{
STRESS_LOG1(LF_SYNC, LL_INFO1000, "RareDisablePreemptiveGC: entering. Thread state = %x\n", m_State.Load());

Expand Down Expand Up @@ -2361,7 +2362,8 @@ void Thread::RareDisablePreemptiveGC()
// thread while in this loop. This happens if you use the COM+
// debugger to suspend this thread and then release it.
if (! ((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) ||
(m_State & (TS_DebugSuspendPending | TS_StackCrawlNeeded))) )
((m_State & TS_DebugSuspendPending) && !IsInForbidSuspendForDebuggerRegion()) ||
(m_State & TS_StackCrawlNeeded)) )
{
break;
}
Expand Down