TSan exam: EllenBinTree, FCPriorityQueue
authorkhizmax <libcds.dev@gmail.com>
Thu, 14 May 2015 21:00:17 +0000 (00:00 +0300)
committerkhizmax <libcds.dev@gmail.com>
Thu, 14 May 2015 21:00:17 +0000 (00:00 +0300)
cds/container/fcpriority_queue.h
cds/intrusive/impl/ellen_bintree.h

index c98f155b57a7b01052273e785c6260fa2ab801df..163537ed778e6462c075e1dd2260477d3f50dffa 100644 (file)
@@ -259,6 +259,9 @@ namespace cds { namespace container {
         {
             assert( pRec );
 
+            // this function is called under FC mutex, so switch TSan off
+            CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
+
             switch ( pRec->op() ) {
             case op_push:
                 assert( pRec->pValPush );
@@ -287,6 +290,8 @@ namespace cds { namespace container {
                 assert(false);
                 break;
             }
+
+            CDS_TSAN_ANNOTATE_IGNORE_RW_END;
         }
         //@endcond
     };
index a3ae991bb8e92ae3078ff81ba9ea8a3e4f6f8afd..c422c24c05f64d8c0f6bae468cdbaed96f0eb8c0 100644 (file)
@@ -1235,25 +1235,28 @@ namespace cds { namespace intrusive {
                 if ( nCmp < 0 ) {
                     if ( res.pGrandParent ) {
                         assert( !res.pLeaf->infinite_key() );
-                        pNewInternal->infinite_key( 0 );
                         // TSan false positive: there is the release fence below, pNewInternal is not linked yet
                         CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
+                        pNewInternal->infinite_key( 0 );
                         key_extractor()(pNewInternal->m_Key, *node_traits::to_value_ptr( res.pLeaf ));
                         CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
                     }
                     else {
                         assert( res.pLeaf->infinite_key() == tree_node::key_infinite1 );
+                        // TSan false positive: there is the release fence below, pNewInternal is not linked yet
+                        CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
                         pNewInternal->infinite_key( 1 );
+                        CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
                     }
                     pNewInternal->m_pLeft.store( static_cast<tree_node *>(pNewLeaf), memory_model::memory_order_relaxed );
                     pNewInternal->m_pRight.store( static_cast<tree_node *>(res.pLeaf), memory_model::memory_order_release );
                 }
                 else {
                     assert( !res.pLeaf->is_internal() );
-                    pNewInternal->infinite_key( 0 );
 
                     // TSan false positive: there is the release fence below, pNewInternal is not linked yet
                     CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
+                    pNewInternal->infinite_key( 0 );
                     key_extractor()(pNewInternal->m_Key, val);
                     CDS_TSAN_ANNOTATE_IGNORE_WRITES_END;
                     pNewInternal->m_pLeft.store( static_cast<tree_node *>(res.pLeaf), memory_model::memory_order_relaxed );