Merge pull request #1718 from madewokherd/sgenthreadcleanup
authormonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 29 Mar 2016 20:01:05 +0000 (21:01 +0100)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Tue, 29 Mar 2016 20:01:05 +0000 (21:01 +0100)
[sgen] Clean up thread pool on shutdown.

Keeping threads around can cause processes to keep running when they shouldn't, particularly on Windows when the entry point returns.

(The reason this is important for me is that Wine provides _CorExeMain, which is an entry point that does return, unlike normal compiled C programs which appear to call exit() after main() returns. A Windows process doesn't exit until ALL threads have exited, so a thread that never exits means a hung process.)

It doesn't seem like we have other GC-specific cleanup code, so I don't know if this is a good approach. Feedback on that question would be appreciated.

1  2 
mono/metadata/sgen-mono.c

index 42f860df05d7bc979130e9672a251d0f4535c5b9,262589f2a995cc5fa7cc70f58f4a216b4adb7614..efa0e892eccf3bd312a72915c482e115c8fad163
  #include "metadata/runtime.h"
  #include "metadata/sgen-bridge-internals.h"
  #include "metadata/gc-internals.h"
 +#include "metadata/handle.h"
  #include "utils/mono-memory-model.h"
  #include "utils/mono-logger-internals.h"
+ #include "sgen/sgen-thread-pool.h"
  
  #ifdef HEAVY_STATISTICS
  static guint64 stat_wbarrier_set_arrayref = 0;