]> granicus.if.org Git - gc/commitdiff
Avoid potential race when storing oh_back_ptr during parallel marking
authorIvan Maidanski <ivmai@mail.ru>
Wed, 7 Mar 2018 17:40:05 +0000 (20:40 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 7 Mar 2018 17:40:05 +0000 (20:40 +0300)
* dbg_mlc.c [KEEP_BACK_PTRS && PARALLEL_MARK] (GC_store_back_pointer):
Store source to dest->oh_back_ptr atomically (unordered atomic store
is sufficient here).

dbg_mlc.c

index 492a3d4c5e3625efef3eeb081f5e63bd916d1f2e..610728da0b1fd2fe2c01cff1b3a242e7481be3f5 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
   GC_INNER void GC_store_back_pointer(ptr_t source, ptr_t dest)
   {
     if (GC_HAS_DEBUG_INFO(dest)) {
-      ((oh *)dest) -> oh_back_ptr = HIDE_BACK_PTR(source);
+#     ifdef PARALLEL_MARK
+        AO_store((volatile AO_t *)&((oh *)dest)->oh_back_ptr,
+                 (AO_t)HIDE_BACK_PTR(source));
+#     else
+        ((oh *)dest) -> oh_back_ptr = HIDE_BACK_PTR(source);
+#     endif
     }
   }