HomePhabricator

Fix lock order inversion in promoteStakeContendersToTip

Description

Fix lock order inversion in promoteStakeContendersToTip

Summary:
Scheduler thread calls:
updatedBlockTip: cs_peerManager -> cs_main
promoteStakeContendersToTip: cs_stakeContendercache -> cs_peerManager

But main thread is calling addStakeContender: cs_main -> cs_stakeContenderCache

Swapping the lock order in promoteStakeContendersToTip fixes TSAN

Test Plan:

cmake -GNinja .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DENABLE_SANITIZERS=thread
ninja check-avalanche-processor_tests

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17058

Details

Provenance
roqqitAuthored on Fri, Nov 1, 17:38
roqqitPushed on Fri, Nov 1, 22:12
Reviewer
Restricted Owners Package
Differential Revision
D17058: Fix lock order inversion in promoteStakeContendersToTip
Parents
rABCf223acc35389: [avalanche] Promote stake contenders when the chain tip updates
Branches
Unknown
Tags
Unknown