[threads] Fix crash on unknown policy (#4264)
[mono.git] / mono / metadata / threads.c
index d874b5664c753ac83209ae3d8b9f7f46ccdfa8a0..b5ffc0202314853e9c36d478c6eab0df86575253 100644 (file)
@@ -476,7 +476,8 @@ mono_thread_internal_set_priority (MonoInternalThread *internal, MonoThreadPrior
                        param.sched_priority = 0;
                        break;
                default:
-                       g_error ("%s: unknown policy %d", __func__, policy);
+                       g_warning ("%s: unknown policy %d", __func__, policy);
+                       return;
                }
        }
 
@@ -1086,6 +1087,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;