From: Ivan Maidanski Date: Wed, 7 Mar 2018 17:40:05 +0000 (+0300) Subject: Avoid potential race when storing oh_back_ptr during parallel marking X-Git-Tag: v8.0.0~294 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=701858e81bff8032262f56b753c7f90facd2ee27;p=gc Avoid potential race when storing oh_back_ptr during parallel marking * 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). --- diff --git a/dbg_mlc.c b/dbg_mlc.c index 492a3d4c..610728da 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -90,7 +90,12 @@ 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 } }