[coop] Temporarily restore MonoThreadInfo when TLS destructor runs. Fixes #43099
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 10 Aug 2016 16:14:52 +0000 (12:14 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Wed, 10 Aug 2016 16:14:52 +0000 (12:14 -0400)
commit57fb9aa164a835543f6b6b7707c778fd4de2a9b1
tree98b47ccec2c114a679212b4a3c7bd45b3e1391c1
parentab14520764785eb4d0364b8490ec007d2aaac229
[coop] Temporarily restore MonoThreadInfo when TLS destructor runs.  Fixes #43099

We need a valid MonoThreadInfo in the TLS key while we run
unregister_thread because we may need to block the thread when it tries
to take the sgen GC mutex.

Fixes [#43099](https://bugzilla.xamarin.com/show_bug.cgi?id=43099)
mono/tests/pinvoke3.cs
mono/utils/mono-threads-state-machine.c
mono/utils/mono-threads.c