diff options
author | Koundinya Veluri <kouvel@microsoft.com> | 2015-11-19 10:51:06 -0800 |
---|---|---|
committer | Koundinya Veluri <kouvel@microsoft.com> | 2015-12-08 11:19:11 -0800 |
commit | b18d2a7e30a0d7066d2c09711de07488a7dec475 (patch) | |
tree | f8d10d42ec0e90e16b1ea390a49b12d3c9638d45 /src | |
parent | 49f5b95ee35535189229525947cdb9af245bb4f9 (diff) | |
download | coreclr-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')
-rw-r--r-- | src/vm/finalizerthread.cpp | 6 |
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) { |