Skip to content

Commit 88289dc

Browse files
authored
Merge pull request #1126 from Unity-Technologies/fix-boehm-thread-pinning
Fix boehm thread pinning
2 parents 081f213 + a38bdc6 commit 88289dc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mono/metadata/threads.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,16 @@ create_internal_thread_object (void)
562562

563563
thread->apartment_state = ThreadApartmentState_Unknown;
564564
thread->managed_id = get_next_managed_thread_id ();
565+
/*
566+
* Boehm incremental is not actually "moving", it does not need the thread_pinning_ref.
567+
* But having it causes problems when unregistering the root after domain reload.
568+
*/
569+
#if !defined(HAVE_BOEHM_GC)
565570
if (mono_gc_is_moving ()) {
566571
thread->thread_pinning_ref = thread;
567572
MONO_GC_REGISTER_ROOT_PINNING (thread->thread_pinning_ref, MONO_ROOT_SOURCE_THREADING, NULL, "Thread Pinning Reference");
568573
}
574+
#endif
569575

570576
thread->priority = MONO_THREAD_PRIORITY_NORMAL;
571577

@@ -883,11 +889,17 @@ mono_thread_detach_internal (MonoInternalThread *thread)
883889
mono_thread_cleanup_fn (thread_get_tid (thread));
884890

885891
mono_memory_barrier ();
886-
892+
893+
/*
894+
* Boehm incremental is not actually "moving", it does not need the thread_pinning_ref.
895+
* But having it causes problems when unregistering the root after domain reload.
896+
*/
897+
#if !defined(HAVE_BOEHM_GC)
887898
if (mono_gc_is_moving ()) {
888899
MONO_GC_UNREGISTER_ROOT (thread->thread_pinning_ref);
889900
thread->thread_pinning_ref = NULL;
890901
}
902+
#endif
891903

892904
done:
893905
SET_CURRENT_OBJECT (NULL);

0 commit comments

Comments
 (0)