summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Robbins <brianrob@microsoft.com>2017-05-31 16:48:56 -0700
committerGitHub <noreply@github.com>2017-05-31 16:48:56 -0700
commitbdc3f84b47d4cd93b6cc6771a52f9c57249ceddb (patch)
tree2eea41f61c5d9bea4f5909caade0b31b76425e2f
parent97c58ac4fce27b7796206a59eea0ca27cb49fe1a (diff)
downloadcoreclr-bdc3f84b47d4cd93b6cc6771a52f9c57249ceddb.tar.gz
coreclr-bdc3f84b47d4cd93b6cc6771a52f9c57249ceddb.tar.bz2
coreclr-bdc3f84b47d4cd93b6cc6771a52f9c57249ceddb.zip
Remove GCX_PREEMP call when allocating a buffer. (#12016)
-rw-r--r--src/vm/eventpipebuffermanager.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vm/eventpipebuffermanager.cpp b/src/vm/eventpipebuffermanager.cpp
index 5edc462542..86a3e03c59 100644
--- a/src/vm/eventpipebuffermanager.cpp
+++ b/src/vm/eventpipebuffermanager.cpp
@@ -283,7 +283,12 @@ bool EventPipeBufferManager::WriteEvent(Thread *pThread, EventPipeEvent &event,
// Check to see if we need to allocate a new buffer, and if so, do it here.
if(allocNewBuffer)
{
- GCX_PREEMP();
+ // We previously switched to preemptive mode here, however, this is not safe and can cause deadlocks.
+ // When a GC is started, and background threads are created (for the first BGC), a thread creation event is fired.
+ // When control gets here the buffer is allocated, but then the thread hangs waiting for the GC to complete
+ // (it was marked as started before creating threads) so that it can switch back to cooperative mode.
+ // However, the GC is waiting on this call to return so that it can make forward progress. Thus it is not safe
+ // to switch to preemptive mode here.
unsigned int requestSize = sizeof(EventPipeEventInstance) + length;
pBuffer = AllocateBufferForThread(pThread, requestSize);