[runtime] Avoid calling mono_thread_current () in sgen_thread_detach (), since it...
authorZoltan Varga <vargaz@gmail.com>
Thu, 15 May 2014 12:05:03 +0000 (14:05 +0200)
committerZoltan Varga <vargaz@gmail.com>
Thu, 15 May 2014 12:05:03 +0000 (14:05 +0200)
mono/metadata/sgen-gc.c
mono/metadata/threads-types.h
mono/metadata/threads.c

index ca21491e48a65ab6ee3fe43647f201428bf2f4c3..f4ad5c1c90c40255fd107f20ff37a17ad3fc8eb6 100644 (file)
@@ -3839,7 +3839,7 @@ sgen_thread_detach (SgenThreadInfo *p)
         * the thread
         */
        if (mono_domain_get ())
-               mono_thread_detach (mono_thread_current ());
+               mono_thread_detach_internal (mono_thread_internal_current ());
 }
 
 static void
index acd263c765ef814ae338dcef47a50991e3772be0..431fe93ea06772bcd61ac9e8c882d1119e345e5e 100644 (file)
@@ -245,4 +245,6 @@ void mono_threads_add_joinable_thread (gpointer tid) MONO_INTERNAL;
 void mono_threads_join_threads (void) MONO_INTERNAL;
 void mono_thread_join (gpointer tid) MONO_INTERNAL;
 
+void mono_thread_detach_internal (MonoInternalThread *thread) MONO_INTERNAL;
+
 #endif /* _MONO_METADATA_THREADS_TYPES_H_ */
index 0733f89900785bbd0206dfec4bd60a11715577fe..3a2d76039715f17a33ccc3f2cea0119e649b4b1e 100755 (executable)
@@ -957,13 +957,13 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach)
 }
 
 void
-mono_thread_detach (MonoThread *thread)
+mono_thread_detach_internal (MonoInternalThread *thread)
 {
        g_return_if_fail (thread != NULL);
 
-       THREAD_DEBUG (g_message ("%s: mono_thread_detach for %p (%"G_GSIZE_FORMAT")", __func__, thread, (gsize)thread->internal_thread->tid));
+       THREAD_DEBUG (g_message ("%s: mono_thread_detach for %p (%"G_GSIZE_FORMAT")", __func__, thread, (gsize)thread->tid));
 
-       thread_cleanup (thread->internal_thread);
+       thread_cleanup (thread);
 
        SET_CURRENT_OBJECT (NULL);
        mono_domain_unset ();
@@ -974,6 +974,13 @@ mono_thread_detach (MonoThread *thread)
         */
 }
 
+void
+mono_thread_detach (MonoThread *thread)
+{
+       if (thread)
+               mono_thread_detach_internal (thread->internal_thread);
+}
+
 void
 mono_thread_exit ()
 {