From 3e78c22f48e6768f98aca816147e92b6c05ed7dc Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Fri, 29 Jun 2012 12:46:39 -0300 Subject: [PATCH] Fix race condition in static's inialization of mono_message_init. * object.c (mono_message_init): Make sure the static field we test fo check for initialization is the last to init or we risk an abort due to others been null. --- mono/metadata/object.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 3489ed27d9c..9b6c568ace0 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "cominterop.h" #ifdef HAVE_BOEHM_GC @@ -5733,23 +5734,18 @@ mono_message_init (MonoDomain *domain, if (!object_array_klass) { MonoClass *klass; - klass = mono_array_class_get (mono_defaults.object_class, 1); - g_assert (klass); - - mono_memory_barrier (); - object_array_klass = klass; - klass = mono_array_class_get (mono_defaults.byte_class, 1); g_assert (klass); - - mono_memory_barrier (); byte_array_klass = klass; klass = mono_array_class_get (mono_defaults.string_class, 1); g_assert (klass); - - mono_memory_barrier (); string_array_klass = klass; + + klass = mono_array_class_get (mono_defaults.object_class, 1); + g_assert (klass); + + mono_atomic_store_release (&object_array_klass, klass); } MONO_OBJECT_SETREF (this, method, method); -- 2.11.4.GIT