Page MenuHomePhabricator

Fix lock order in Avalanche event loop
AbandonedPublic

Authored by jasonbcox on Apr 9 2020, 21:33.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Summary

In validation thread(s), the typical lock order is cs_main -> cs_vNodes.
Avalanche reverses this by trying to lock cs_vNodes -> cs_main, tripping the deadlock
detection.

Following the same pattern as net_processing, we can lock cs_main and assert the lock
is still held within the ForNode() lambda. This ensures the same lock order as other
threads.

Test Plan
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug ..
for i in {1..20}; do ./test/functional/test_runner.py abc-p2p-ava* ; done

There's still some rarer flaky behavior in this test, but none of the failures should
indicate a deadlock in debug.log.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
ava-locks
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10158
Build 18142: Default Diff Build & Tests
Build 18141: arc lint + arc unit