Merge pull request #3321 from BrzVlad/fix-block-state-membar
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 21 Jul 2016 22:34:41 +0000 (15:34 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Jul 2016 22:34:41 +0000 (15:34 -0700)
[sgen] Add missing memory barrier

mono/sgen/sgen-marksweep.c

index 8b4f3cb612dd4370c6f96a04798abf26ec1cc6cb..6a20d0c57fad1e275e2ffc9e213c3bd385f94155 100644 (file)
@@ -1572,6 +1572,12 @@ ensure_block_is_checked_for_sweeping (guint32 block_index, gboolean wait, gboole
        }
 
  done:
+       /*
+        * Once the block is written back without the checking bit other threads are
+        * free to access it. Make sure the block state is visible before we write it
+        * back.
+        */
+       mono_memory_write_barrier ();
        *block_slot = tagged_block;
        return !!tagged_block;
 }