[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: