[threadpool] Fix race on runtime shutdown (#4263)
authorLudovic Henry <ludovic@xamarin.com>
Thu, 19 Jan 2017 14:30:07 +0000 (09:30 -0500)
committerGitHub <noreply@github.com>
Thu, 19 Jan 2017 14:30:07 +0000 (09:30 -0500)
commit3c3e566002bfd185cc178b1bd139f1f606faee16
tree840e34f633490894c67a0f66923fbb08d54f0605
parente343ad0cfd404c92761cd6e0f683ccd46402897b
[threadpool] Fix race on runtime shutdown (#4263)

We cannot free the threadpool, because there is a race on shutdown where a managed thread may request a new threadpool thread, but we already destroyed the threadpool. So to avoid a use-after-free, we simply do not free the threadpool, as we won't be able to access the threadpool anyway because the ref count will be 0

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=51219
mono/metadata/threadpool.c
mono/utils/refcount.h