From: Andrew Au Date: Mon, 6 Aug 2018 22:04:37 +0000 (-0700) Subject: Fixing the deadlocks X-Git-Tag: submit/tizen/20210909.063632~11030^2~3465 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a903e61ff509391506ca09a20abac86f496e470;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Fixing the deadlocks Commit migrated from https://github.com/dotnet/coreclr/commit/e467645dbefa58e144a42c3b742cee859b68d55d --- diff --git a/src/coreclr/src/debug/ee/debugger.cpp b/src/coreclr/src/debug/ee/debugger.cpp index b9decbc..e8134a4 100644 --- a/src/coreclr/src/debug/ee/debugger.cpp +++ b/src/coreclr/src/debug/ee/debugger.cpp @@ -6057,9 +6057,7 @@ void Debugger::AfterGarbageCollection() return; { - Debugger::DebuggerLockHolder dbgLockHolder(this); - - this->m_isBlockedOnGarbageCollectionEvent = true; + Debugger::DebuggerLockHolder dbgLockHolder(this); DebuggerIPCEvent* ipce1 = m_pRCThread->GetIPCEventSendBuffer(); InitIPCEvent(ipce1, @@ -6073,6 +6071,7 @@ void Debugger::AfterGarbageCollection() WaitForSingleObject(this->GetGarbageCollectionBlockerEvent(), INFINITE); ResetEvent(this->GetGarbageCollectionBlockerEvent()); + this->m_isBlockedOnGarbageCollectionEvent = false; } void Debugger::SendDataBreakpoint(Thread *thread, CONTEXT *context, @@ -10817,7 +10816,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) _ASSERTE(ThreadHoldsLock()); // Simply trap all Runtime threads if we're not already trying to. - if (!m_trappingRuntimeThreads) + if (!m_isBlockedOnGarbageCollectionEvent && !m_trappingRuntimeThreads) { // If the RS sent an Async-break, then that's an explicit request. m_RSRequestedSync = TRUE; @@ -10831,7 +10830,6 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) { if (this->m_isBlockedOnGarbageCollectionEvent) { - this->m_isBlockedOnGarbageCollectionEvent = false; this->m_stopped = false; SetEvent(this->GetGarbageCollectionBlockerEvent()); } diff --git a/src/coreclr/src/debug/ee/debugger.h b/src/coreclr/src/debug/ee/debugger.h index 7e0134d..a07531b 100644 --- a/src/coreclr/src/debug/ee/debugger.h +++ b/src/coreclr/src/debug/ee/debugger.h @@ -2218,7 +2218,7 @@ public: unsigned int errorLine, bool exitThread); - BOOL IsSynchronizing(void) + virtual BOOL IsSynchronizing(void) { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/src/vm/dbginterface.h b/src/coreclr/src/vm/dbginterface.h index a855a10..d0be137 100644 --- a/src/coreclr/src/vm/dbginterface.h +++ b/src/coreclr/src/vm/dbginterface.h @@ -412,6 +412,7 @@ public: virtual void BeforeGarbageCollection() = 0; virtual void AfterGarbageCollection() = 0; #endif + virtual BOOL IsSynchronizing() = 0; }; #ifndef DACCESS_COMPILE diff --git a/src/coreclr/src/vm/threadsuspend.cpp b/src/coreclr/src/vm/threadsuspend.cpp index 822c396..1902d82 100644 --- a/src/coreclr/src/vm/threadsuspend.cpp +++ b/src/coreclr/src/vm/threadsuspend.cpp @@ -7108,7 +7108,7 @@ retry_for_debugger: || Thread::ThreadsAtUnsafePlaces() #ifdef DEBUGGING_SUPPORTED // seriously? When would we want to disable debugging support? :) || (CORDebuggerAttached() && - g_pDebugInterface->ThreadsAtUnsafePlaces()) + (g_pDebugInterface->ThreadsAtUnsafePlaces() || g_pDebugInterface->IsSynchronizing())) #endif // DEBUGGING_SUPPORTED ) {