[threads] Store MonoInternalThread in MonoThreadInfo for use when detaching (#5058)
authorLudovic Henry <ludovic@xamarin.com>
Tue, 20 Jun 2017 00:35:54 +0000 (20:35 -0400)
committerGitHub <noreply@github.com>
Tue, 20 Jun 2017 00:35:54 +0000 (20:35 -0400)
commita08574bf9e4f27e3187a3f6edf7d99d32c28ad6c
tree2e754359624756f649d212e5047bf30de49001b4
parent3765f987d5c6d5ac4d11f1a3908797f420770dc0
[threads] Store MonoInternalThread in MonoThreadInfo for use when detaching (#5058)

* [threads] Make mono_thread_attach_full static

* [threads] Remove  prefix on MonoThreadInfoCallbacks callbacks

* [threads] Rename mono_threads*_init functions to mono_thread_info*_init

* [threads] Remove dead method mono_runtime_is_critical_method

* [threads] Move MonoThreadInfoCallbacks to metadata/threads

* [threads] Store MonoInternalThread in MonoThreadInfo for use when detaching

When the native thread would exit, the TLS keys are destroyed. There is a TLS destructor for MonoThreadInfo, but not for MonoInternalThread. If MonoInternalThread is destroyed before MonoThreadInfo, then MonoThreadInfoCallbacks.thread_detach wouldn't successfully detach the current MonoInternalThread as mono_thread_internal_current would return NULL. This would lead to MonoInternalThread still laying around, while their corresponding MonoThreadInfo has already been destroyed. This fixes this problem, since we now rely on MonoThreadInfo to store the MonoInternalThread for detach.
15 files changed:
mono/dis/main.c
mono/metadata/boehm-gc.c
mono/metadata/gc-internals.h
mono/metadata/null-gc.c
mono/metadata/runtime.c
mono/metadata/runtime.h
mono/metadata/sgen-mono.c
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/mini/mini-runtime.c
mono/unit-tests/test-conc-hashtable.c
mono/unit-tests/test-mono-linked-list-set.c
mono/utils/mono-threads.c
mono/utils/mono-threads.h
tools/pedump/pedump.c