Page MenuHomePhabricator

Merge #18487: rpc: Fix rpcRunLater race in walletpassphrase
ClosedPublic

Authored by jasonbcox on Oct 13 2020, 16:26.

Details

Summary

7b8e15728d1ad058a4b7d7569fd5d5ba6806ca28 rpc: Fix rpcRunLater race in walletpassphrase (João Barbosa)

Pull request description:

Release locks before calling `rpcRunLater`.

Quick explanation: `rpcRunLater` leads to `event_free` which calls `event_del` which can wait for the event callback to finish if it's already running and that callback will try to lock wallet mutex - which is already locked in http thread.

Fixes #14995 , fixes #18482. Best reviewed with whitespace changes hidden.

Backport of Core PR18487
Fixes https://github.com/Bitcoin-ABC/bitcoin-abc/issues/375

Test Plan

ninja check check-functional

Event Timeline

Snippet of first build failure:

wallet_hd.py                                     | ○ Skipped | 0 s
wallet_import_rescan.py                          | ○ Skipped | 0 s
wallet_import_with_label.py                      | ○ Skipped | 0 s
wallet_importmulti.py                            | ○ Skipped | 0 s
wallet_importprunedfunds.py                      | ○ Skipped | 0 s
wallet_keypool.py                                | ○ Skipped | 0 s
wallet_keypool_topup.py                          | ○ Skipped | 0 s
wallet_labels.py                                 | ○ Skipped | 0 s
wallet_listreceivedby.py                         | ○ Skipped | 0 s
wallet_listsinceblock.py                         | ○ Skipped | 0 s
wallet_listtransactions.py                       | ○ Skipped | 0 s
wallet_multiwallet.py                            | ○ Skipped | 0 s
wallet_multiwallet.py --usecli                   | ○ Skipped | 0 s
wallet_reorgsrestore.py                          | ○ Skipped | 0 s
wallet_resendwallettransactions.py               | ○ Skipped | 0 s
wallet_txn_clone.py                              | ○ Skipped | 0 s
wallet_txn_clone.py --mineblock                  | ○ Skipped | 0 s
wallet_txn_doublespend.py                        | ○ Skipped | 0 s
wallet_txn_doublespend.py --mineblock            | ○ Skipped | 0 s
wallet_watchonly.py                              | ○ Skipped | 0 s
wallet_watchonly.py --usecli                     | ○ Skipped | 0 s
wallet_zapwallettxes.py                          | ○ Skipped | 0 s
p2p_invalid_messages.py                          | ✖ Failed  | 4 s

ALL                                              | ✖ Failed  | 270 s (accumulated) 
Runtime: 54 s

[22/379] Test Bitcoin RPC authentication...
...
----------------------------------------------------------------------
Ran 3 tests in 0.004s

OK
[23/379] cd /work/contrib/devtools/chainparams && /usr/bin/python3.7 ./test_make_chainparams.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.001s

OK
[115/379] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/script_tests.cpp.o
In file included from /usr/include/boost/test/unit_test.hpp:19,
                 from ../../src/test/script_tests.cpp:30:
../../src/test/script_tests.cpp: In member function ‘void script_tests::script_build::test_method()’:
../../src/test/script_tests.cpp:541:22: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
 BOOST_AUTO_TEST_CASE(script_build) {
                      ^~~~~~~~~~~~
[156/379] Running seeder test suite
PASSED: seeder test suite
[164/379] Running avalanche test suite
PASSED: avalanche test suite
[167/379] Running bitcoin-qt test suite
PASSED: bitcoin-qt test suite
[357/379] Running pow test suite
PASSED: pow test suite
[378/379] Running bitcoin test suite
PASSED: bitcoin test suite
FAILED: test/CMakeFiles/check-functional 
cd /work/abc-ci-builds/build-without-wallet/test && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-without-wallet/test/junit && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-without-wallet/test/log && /usr/bin/cmake -E env /usr/bin/python3.7 ./functional/test_runner.py "--testsuitename=Bitcoin ABC functional tests" --junitoutput=/work/abc-ci-builds/build-without-wallet/test/junit/functional_tests.xml
ninja: build stopped: cannot make progress due to previous errors.
Build build-without-wallet failed with exit code 1

Each failure log is accessible here:
Bitcoin ABC functional tests: p2p_invalid_messages.py

This revision is now accepted and ready to land.Oct 13 2020, 16:43