summaryrefslogtreecommitdiff
path: root/src/vm
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@microsoft.com>2015-11-19 10:51:06 -0800
committerKoundinya Veluri <kouvel@microsoft.com>2015-12-08 11:19:11 -0800
commitb18d2a7e30a0d7066d2c09711de07488a7dec475 (patch)
treef8d10d42ec0e90e16b1ea390a49b12d3c9638d45 /src/vm
parent49f5b95ee35535189229525947cdb9af245bb4f9 (diff)
downloadcoreclr-b18d2a7e30a0d7066d2c09711de07488a7dec475.tar.gz
coreclr-b18d2a7e30a0d7066d2c09711de07488a7dec475.tar.bz2
coreclr-b18d2a7e30a0d7066d2c09711de07488a7dec475.zip
Disable suspend on shutdown during shutdown finalization
The main thread does not time out waiting for the finalizer thread to complete during shutdown. Cases examined had the main thread blocked waiting for the finalizer thread to complete its work. The finalizer thread was blocked on either the "waiting for GC completion" event or one of the the GC spinlocks. Another thread was blocked for shutdown after entering the spinlock while allocating, or during GC. Allowing other threads to suspend for shutdown could cause the finalizer thread to block indefinitely, leading to a deadlock.
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/finalizerthread.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/vm/finalizerthread.cpp b/src/vm/finalizerthread.cpp
index aca97e3ff2..b9895742a0 100644
--- a/src/vm/finalizerthread.cpp
+++ b/src/vm/finalizerthread.cpp
@@ -1207,6 +1207,11 @@ BOOL FinalizerThread::FinalizerThreadWatchDog()
#endif //BACKGROUND_GC
_ASSERTE ((g_fEEShutDown & ShutDown_Finalize1) || g_fFastExitProcess);
+
+ // FinalizerThreadWatchDogHelper does not time out waiting for the finalizer thread in CoreCLR. If another thread blocks
+ // during GC for shutdown, a finalizer that allocates (or even jitting a finalizer, which does allocation) may block the
+ // finalizer thread indefinitely, which may in turn lead to a deadlock.
+#ifndef FEATURE_CORECLR
ThreadSuspend::SuspendEE(ThreadSuspend::SUSPEND_FOR_SHUTDOWN);
g_fSuspendOnShutdown = TRUE;
@@ -1217,6 +1222,7 @@ BOOL FinalizerThread::FinalizerThreadWatchDog()
ThreadStore::TrapReturningThreads(TRUE);
ThreadSuspend::RestartEE(FALSE, TRUE);
+#endif
if (g_fFastExitProcess)
{