Skip to content

Commit 422efca

Browse files
committed
Merge bitcoin/bitcoin#26188: test: silence TSAN false positive in coinstatsindex_initial_sync
861cb3f test: move SyncWithValidationInterfaceQueue() before Stop() in txindex_tests (Vasil Dimov) 6526dc3 test: silence TSAN false positive in coinstatsindex_initial_sync (Vasil Dimov) Pull request description: Silence false positives from TSAN about unsynchronized calls to `BaseIndex::~BaseIndex()` and `BaseIndex::SetBestBlockIndex()`. They are synchronized, but beyond the comprehension of TSAN - by `SyncWithValidationInterfaceQueue()`, called from `BaseIndex::BlockUntilSyncedToCurrentChain()`. Fixes bitcoin/bitcoin#25365 ACKs for top commit: MarcoFalke: review ACK 861cb3f ryanofsky: Code review ACK 861cb3f. Just comment change since last review. Tree-SHA512: 8c30fdf2fd11d54e9adfa68a67185ab820bd7bd9f7f3ad6456e7e6d219fa9cf6d34b41e98e723eae86cb0c1baef7f3fc57b1b011a13dc3fe3d78334b9b5596de
2 parents 7e1007a + 861cb3f commit 422efca

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/test/coinstatsindex_tests.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
7676

7777
BOOST_CHECK(block_index != new_block_index);
7878

79+
// It is not safe to stop and destroy the index until it finishes handling
80+
// the last BlockConnected notification. The BlockUntilSyncedToCurrentChain()
81+
// call above is sufficient to ensure this, but the
82+
// SyncWithValidationInterfaceQueue() call below is also needed to ensure
83+
// TSAN always sees the test thread waiting for the notification thread, and
84+
// avoid potential false positive reports.
85+
SyncWithValidationInterfaceQueue();
86+
7987
// Shutdown sequence (c.f. Shutdown() in init.cpp)
8088
coin_stats_index.Stop();
81-
82-
// Rest of shutdown sequence and destructors happen in ~TestingSetup()
8389
}
8490

8591
// Test shutdown between BlockConnected and ChainStateFlushed notifications,

src/test/txindex_tests.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,16 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
6969
}
7070
}
7171

72+
// It is not safe to stop and destroy the index until it finishes handling
73+
// the last BlockConnected notification. The BlockUntilSyncedToCurrentChain()
74+
// call above is sufficient to ensure this, but the
75+
// SyncWithValidationInterfaceQueue() call below is also needed to ensure
76+
// TSAN always sees the test thread waiting for the notification thread, and
77+
// avoid potential false positive reports.
78+
SyncWithValidationInterfaceQueue();
79+
7280
// shutdown sequence (c.f. Shutdown() in init.cpp)
7381
txindex.Stop();
74-
75-
// Let scheduler events finish running to avoid accessing any memory related to txindex after it is destructed
76-
SyncWithValidationInterfaceQueue();
7782
}
7883

7984
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)