From 762ac3d618a5eaddedb90362c684fe4aef2cff9a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 15 Jun 2017 13:50:10 -0400 Subject: [PATCH] In mono_thread_info_suspend_lock in non-coop, don't assert MonoThreadInfo* is non-NULL mono_thread_info_suspend_lock () can be called from boehm-gc.c on_gc_notification before the new thread's start_wrapper calls mono_thread_info_attach but after pthread_create calls the start wrapper. As a result, the asserts in mono_thread_info_suspend_lock_with_info can catch the new thread in an inconsistent state. --- mono/utils/mono-threads.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index dac28b7037d..6afb74daf8d 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -1029,16 +1029,21 @@ STW to make sure no unsafe pending suspend is in progress. static void mono_thread_info_suspend_lock_with_info (MonoThreadInfo *info) { - g_assert (info); - g_assert (mono_thread_info_is_current (info)); - g_assert (mono_thread_info_is_live (info)); + if (mono_threads_is_coop_enabled ()) { + g_assert (info); + g_assert (mono_thread_info_is_current (info)); + g_assert (mono_thread_info_is_live (info)); - MONO_ENTER_GC_SAFE_WITH_INFO(info); + MONO_ENTER_GC_SAFE_WITH_INFO(info); - int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); - g_assert (res != -1); + int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); + g_assert (res != -1); - MONO_EXIT_GC_SAFE_WITH_INFO; + MONO_EXIT_GC_SAFE_WITH_INFO; + } else { + int res = mono_os_sem_wait (&global_suspend_semaphore, MONO_SEM_FLAGS_NONE); + g_assert (res != -1); + } } void -- 2.11.4.GIT