]> granicus.if.org Git - gc/commitdiff
Eliminate TSan warning about non-atomic read in store_back_pointer
authorIvan Maidanski <ivmai@mail.ru>
Mon, 12 Mar 2018 22:23:49 +0000 (01:23 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 13 Mar 2018 06:41:53 +0000 (09:41 +0300)
(fix of commit 701858e)

* include/private/dbg_mlc.h [PARALLEL_MARK && KEEP_BACK_PTRS]
(GC_HAS_DEBUG_INFO): Use AO_load to access the word pointed by p; add
comment.

include/private/dbg_mlc.h

index 4283bdac9eea0592ffc456a33b920605038de7df..02c951138c9819397d8945c40c6a0a0c47173328 100644 (file)
@@ -163,11 +163,20 @@ typedef struct {
 #   error Non-ptr stored in object results in GC_HAS_DEBUG_INFO malfunction
     /* We may mistakenly conclude that p has a debugging wrapper.       */
 # endif
-# define GC_HAS_DEBUG_INFO(p) \
-        ((*((word *)p) & 1) && GC_has_other_debug_info(p) > 0)
+# if defined(PARALLEL_MARK) && defined(KEEP_BACK_PTRS)
+#   define GC_HAS_DEBUG_INFO(p) \
+                ((AO_load((volatile AO_t *)(p)) & 1) != 0 \
+                 && GC_has_other_debug_info(p) > 0)
+                        /* Atomic load is used as GC_store_back_pointer */
+                        /* stores oh_back_ptr atomically (p might point */
+                        /* to the field); this prevents a TSan warning. */
+# else
+#   define GC_HAS_DEBUG_INFO(p) \
+                ((*(word *)(p) & 1) && GC_has_other_debug_info(p) > 0)
+# endif
 #else
 # define GC_HAS_DEBUG_INFO(p) (GC_has_other_debug_info(p) > 0)
-#endif
+#endif /* !KEEP_BACK_PTRS && !MAKE_BACK_GRAPH */
 
 EXTERN_C_END