From 701858e81bff8032262f56b753c7f90facd2ee27 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 7 Mar 2018 20:40:05 +0300 Subject: [PATCH] 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). --- dbg_mlc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 } } -- 2.40.0