0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-06 10:18:44 -05:00
bitcoin-bitcoin-core/src/wallet/test
MarcoFalke f3d27d126b
Merge #16033: Hold cs_main when reading chainActive via getTipLocator(). Remove assumeLocked().
9402ef0739 Remove temporary method assumeLocked(). Remove LockingStateImpl. Remove redundant cs_main locks. (practicalswift)
593a8e8a2c wallet: Use chain.lock() instead of temporary chain.assumeLocked() (practicalswift)

Pull request description:

  Fixes #16028.

  Problem description:

  `LockAnnotation lock(::cs_main)` is a guarantee to the compiler thread analysis that `::cs_main` is locked (when it couldn't be determined otherwise).

  Despite being annotated with the locking guarantee ...

  65526fc866/src/interfaces/chain.cpp (L134-L138)

  ... `getTipLocator()` reads `chainActive` (via `::ChainActive()`) without holding `cs_main`.

  This can be verified by adding the following `AssertLockHeld(cs_main)`:

  ```
  $ git diff
  diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
  index 59623284d..9fc693a0f 100644
  --- a/src/interfaces/chain.cpp
  +++ b/src/interfaces/chain.cpp
  @@ -134,6 +134,7 @@ class LockImpl : public Chain::Lock
       CBlockLocator getTipLocator() override
       {
           LockAnnotation lock(::cs_main);
  +        AssertLockHeld(::cs_main);
           return ::ChainActive().GetLocator();
       }
       Optional<int> findLocatorFork(const CBlockLocator& locator) override
  $ make check
  ../build-aux/test-driver: line 107: 12881 Aborted                 "$@" > $log_file 2>&1
  FAIL: qt/test/test_bitcoin-qt
  ```

ACKs for commit 9402ef:
  MarcoFalke:
    utACK 9402ef0739
  ryanofsky:
    utACK 9402ef0739. Changes are consolidating commits and removing redundant lock2 cs_main calls

Tree-SHA512: 0a030bf0c07eb53194ecc246f973ef389dd42a0979f51932bf94bdf7e90c52473ae03be49718ee1629582b05dd8e0dc020b5a210318c93378ea4ace90c0f9f72
2019-05-17 07:17:41 -04:00
..
coinselector_tests.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
db_tests.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
init_test_fixture.cpp Remove direct node->wallet calls in init.cpp 2018-11-06 11:44:40 -04:00
init_test_fixture.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
init_tests.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
psbt_wallet_tests.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
wallet_crypto_tests.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
wallet_test_fixture.cpp scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
wallet_test_fixture.h scripted-diff: Bump copyright headers in wallet 2019-05-06 14:05:52 -04:00
wallet_tests.cpp Remove temporary method assumeLocked(). Remove LockingStateImpl. Remove redundant cs_main locks. 2019-05-16 21:43:22 +02:00