Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonojenkins <jo.shields+jenkins@xamarin.com>2021-02-05 14:30:52 +0300
committerGitHub <noreply@github.com>2021-02-05 14:30:52 +0300
commit54460c9be9109fdd44bf224a40a8a99ad0fb845e (patch)
tree51697da4becd9421b48a52fe8b58c3419fbad707
parent9a7219d3be5c595623c7b0e69b9c12312b9c4c1d (diff)
Ensure mono_gc_thread_detach is always called (#20822)
The previous logic would not call `mono_gc_thread_detach` for a number of scenarios. One example: ``` start_wrapper - mono_thread_info_attach - thread is now live in mono threads layer - start_wrapper_internal -- mono_thread_attach_internal - mono attached to vm thread layer. GC handle is set via mono_thread_info_set_internal_thread_gchandle -- mono_thread_detach_internal - detached from vm thread layer. GC handle cleared via call to mono_thread_info_unset_internal_thread_gchandle - mono_thread_info_exit -- mono_thread_info_detach --- unregister_thread ---- thread_detach callback - checks if gc handle is valid and returns if not via mono_thread_info_try_get_internal_thread_gchandle. We've already cleared above so we never call mono_gc_thread_detach. ``` This change ensures `mono_gc_thread_detach` is always called even the GC handle for the thread has already been cleared. Co-authored-by: joncham <joncham@users.noreply.github.com>
-rw-r--r--mono/metadata/threads.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
index f106af5707c..be3416c30b7 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -3573,13 +3573,12 @@ thread_detach (MonoThreadInfo *info)
g_assert (info);
g_assert (mono_thread_info_is_current (info));
- if (!mono_thread_info_try_get_internal_thread_gchandle (info, &gchandle))
- return;
-
- internal = (MonoInternalThread*) mono_gchandle_get_target_internal (gchandle);
- g_assert (internal);
+ if (mono_thread_info_try_get_internal_thread_gchandle (info, &gchandle)) {
+ internal = (MonoInternalThread*)mono_gchandle_get_target_internal (gchandle);
+ g_assert (internal);
- mono_thread_detach_internal (internal);
+ mono_thread_detach_internal (internal);
+ }
mono_gc_thread_detach (info);
}