From f4fdfcc714328cba1379f25590aa51128c558743 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 16 Dec 2016 13:42:36 -0500 Subject: [PATCH] [threads] Ensure thread is still alive when detaching it If the compiler optimized it so that we would unregister the thread->thread_pinning_ref GC root before we would destroy the thread fields, we could run into "* Assertion at threads.c:1081, condition 'thread->suspended' not met" --- mono/metadata/threads.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index d874b5664c7..fd424bdfb90 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -1086,6 +1086,8 @@ mono_thread_detach_internal (MonoInternalThread *thread) if (mono_thread_cleanup_fn) mono_thread_cleanup_fn (thread_get_tid (thread)); + mono_memory_barrier (); + if (mono_gc_is_moving ()) { MONO_GC_UNREGISTER_ROOT (thread->thread_pinning_ref); thread->thread_pinning_ref = NULL; -- 2.25.1