]> granicus.if.org Git - gc/commitdiff
Workaround TSan false positive in [set_]mark_bit_from_hdr
authorIvan Maidanski <ivmai@mail.ru>
Tue, 31 Oct 2017 08:49:55 +0000 (11:49 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 31 Oct 2017 21:19:59 +0000 (00:19 +0300)
There is no data race between GC_set_fl_marks and GC_is_marked because
bit_no is different.

* include/private/gc_priv.h [THREADS && THREAD_SANITIZER]: Include
gc_atomic_ops.h.
* include/private/gc_priv.h [!USE_MARK_BYTES && THREAD_SANITIZER
&& THREADS] (OR_WORD): Use AO_or; update comment.

include/private/gc_priv.h

index e10bcfde564ef796ecc55081c765c2f493b1eb21..7b1bc6ee2cd363946f7d6adcf6995575535ccb09 100644 (file)
@@ -947,7 +947,7 @@ typedef word page_hash_table[PHT_SIZE];
 # define counter_t volatile AO_t
 #else
   typedef size_t counter_t;
-# if defined(THREADS) && (defined(MPROTECT_VDB) \
+# if defined(THREADS) && (defined(MPROTECT_VDB) || defined(THREAD_SANITIZER) \
                 || (defined(GC_ASSERTIONS) && defined(THREAD_LOCAL_ALLOC)))
 #   include "gc_atomic_ops.h"
 # endif
@@ -1597,8 +1597,11 @@ struct GC_traced_stack_sect_s {
 #else
 /* Set mark bit correctly, even if mark bits may be concurrently        */
 /* accessed.                                                            */
-# ifdef PARALLEL_MARK
-    /* This is used only if we explicitly set USE_MARK_BITS.    */
+# if defined(PARALLEL_MARK) || (defined(THREAD_SANITIZER) && defined(THREADS))
+    /* Workaround TSan false positive: there is no race between         */
+    /* mark_bit_from_hdr and set_mark_bit_from_hdr when n is different  */
+    /* (alternatively, USE_MARK_BYTES could be used).  If TSan is off,  */
+    /* AO_or() is used only if we set USE_MARK_BITS explicitly.         */
 #   define OR_WORD(addr, bits) AO_or((volatile AO_t *)(addr), (AO_t)(bits))
 # else
 #   define OR_WORD(addr, bits) (void)(*(addr) |= (bits))