dash/src
Wladimir J. van der Laan 2f8512b923
Merge #11126: Acquire cs_main lock before cs_wallet during wallet initialization
de9a1db Acquire cs_main lock before cs_wallet during wallet initialization (Russell Yanofsky)

Pull request description:

  `CWallet::MarkConflicted` may acquire the `cs_main` lock after `CWalletDB::LoadWallet` acquires the `cs_wallet` lock during wallet initialization. (`CWalletDB::LoadWallet` calls `ReadKeyValue` which calls `CWallet::LoadToWallet` which calls `CWallet::MarkConflicted`). This is the opposite order that `cs_main` and `cs_wallet` locks are acquired in the rest of the code, and so leads to `POTENTIAL DEADLOCK DETECTED` errors if bitcoin is built with `-DDEBUG_LOCKORDER`.

  This commit changes `CWallet::LoadWallet` (which calls `CWalletDB::LoadWallet`) to acquire both locks in the standard order.

  Error was reported by @luke-jr in https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/

Tree-SHA512: 353fe21bc0a4a2828b41876897001a3c414d4b115ee7430925bd391d8bc396fca81661145d00996c1ba1a01516d9acf8b89fb5c3da27092f5f3aa7e37ef26ffa
2019-07-12 12:31:47 -05:00
..
bench scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
bls Fix excessive memory use when flushing chainstate and EvoDB (#3008) 2019-07-02 07:16:27 +03:00
compat Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
config
consensus Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
crypto Merge #10521: Limit variable scope 2019-07-08 13:50:05 -05:00
evo REJECT_CONFLICT -> REJECT_DUPLICATE 2019-07-09 13:09:21 -05:00
governance Optimize on-disk deterministic masternode storage to reduce size of evodb (#3017) 2019-07-09 08:59:57 +03:00
immer Update immer library to current master (0a718d2d76bab6ebdcf43de943bd6c7d2dbfe2f9) (#2821) 2019-04-01 14:10:49 +03:00
leveldb Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
llmq Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
masternode Optimize on-disk deterministic masternode storage to reduce size of evodb (#3017) 2019-07-09 08:59:57 +03:00
obj
obj-test
policy scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
primitives Merge #10523: Perform member initialization in initialization lists where possible 2019-07-08 10:24:26 -05:00
privatesend Backport #8694: Basic multiwallet support (#3022) 2019-07-11 10:50:52 +03:00
qt Merge #10295: [qt] Move some WalletModel functions into CWallet 2019-07-11 10:34:46 -05:00
rpc Merge #10446: net: avoid extra dns query per seed 2019-07-11 10:34:46 -05:00
script Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
secp256k1 Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
support Merge #9517: [refactor] Switched httpserver.cpp to use RAII wrapped libevents. 2019-07-11 10:34:46 -05:00
test Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
univalue
wallet Merge #11126: Acquire cs_main lock before cs_wallet during wallet initialization 2019-07-12 12:31:47 -05:00
zmq Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
.clang-format Merge #10602: Make clang-format use C++11 features (e.g. A<A<int>> instead of A<A<int> >) 2019-07-09 13:08:21 -05:00
addrdb.cpp Merge #10248: Rewrite addrdb with less duplication using CHashVerifier 2019-07-11 10:34:46 -05:00
addrdb.h Merge #10248: Rewrite addrdb with less duplication using CHashVerifier 2019-07-11 10:34:46 -05:00
addressindex.h
addrman.cpp Merge pull request #2974 from PastaPastaPasta/backports-0.15-pr14 2019-06-19 14:30:54 +03:00
addrman.h Merge pull request #2974 from PastaPastaPasta/backports-0.15-pr14 2019-06-19 14:30:54 +03:00
amount.h Merge #9279: Consensus: Move CFeeRate out of libconsensus 2019-06-26 15:26:07 -05:00
arith_uint256.cpp Merge #10530: Fix invalid instantiation and possibly unsafe accesses of array in class base_uint<BITS> 2019-07-11 10:34:46 -05:00
arith_uint256.h Merge #10530: Fix invalid instantiation and possibly unsafe accesses of array in class base_uint<BITS> 2019-07-11 10:34:46 -05:00
base58.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
base58.h
batchedlogger.cpp Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
batchedlogger.h Backport Bitcoin#9424, Bitcoin#10123 and Bitcoin#10153 (#2918) 2019-05-23 00:51:39 +03:00
bip39_english.h
bip39.cpp
bip39.h
blockencodings.cpp Merge #10553: Simplify "bool x = y ? true : false". Remove unused function and trailing semicolon. 2019-07-09 13:08:20 -05:00
blockencodings.h
bloom.cpp scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
bloom.h Merge #9750: Bloomfilter: parameter variables made constant 2019-06-24 11:39:34 -05:00
cachemap.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
cachemultimap.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
chain.cpp Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
chain.h Add blocks conflicting with ChainLocks to block index (#2923) 2019-05-16 10:12:36 +02:00
chainparams.cpp update seeds emplace_back based on code review 2019-07-12 11:34:49 -05:00
chainparams.h Merge #10446: net: avoid extra dns query per seed 2019-07-11 10:34:46 -05:00
chainparamsbase.cpp Merge #8855: Use a proper factory for creating chainparams 2019-06-26 12:45:10 -05:00
chainparamsbase.h Merge #8855: Use a proper factory for creating chainparams 2019-06-26 12:45:10 -05:00
chainparamsseeds.h
checkpoints.cpp
checkpoints.h
checkqueue.h scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
clientversion.cpp
clientversion.h Merge #10168: Fix build warning from #error text 2019-06-14 01:25:59 -05:00
coins.cpp Merge #10538: [trivial] Fix typo: "occurrences" (misspelled as "occurrances") 2019-05-19 20:43:03 -05:00
coins.h Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
compat.h Merge #9921: build: Probe MSG_DONTWAIT in the same way as MSG_NOSIGNAL 2019-05-06 14:51:42 -05:00
compressor.cpp
compressor.h
core_io.h Backport 8824 (#2968) 2019-06-11 14:42:17 +03:00
core_memusage.h Merge #9208: Improve DisconnectTip performance 2019-06-24 11:39:34 -05:00
core_read.cpp Merge #10545: Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of 2019-07-08 10:24:30 -05:00
core_write.cpp scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
ctpl.h
cuckoocache.h Merge #10577: Add an explanation of quickly hashing onto a non-power of two range. 2019-07-11 10:34:46 -05:00
cxxtimer.hpp
dash-cli-res.rc
dash-cli.cpp Merge pull request #3007 from PastaPastaPasta/backports-0.15-pr17 2019-07-08 18:16:05 +03:00
dash-tx-res.rc
dash-tx.cpp Merge #10536: Remove unreachable or otherwise redundant code 2019-07-11 10:34:46 -05:00
dashd-res.rc
dashd.cpp Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
dbwrapper.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
dbwrapper.h Optimize on-disk deterministic masternode storage to reduce size of evodb (#3017) 2019-07-09 08:59:57 +03:00
dsnotificationinterface.cpp Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
dsnotificationinterface.h Drop CDSNotificationInterface::SyncTransaction() 2019-05-28 11:59:55 +02:00
flat-database.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
fs.cpp Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
fs.h Merge #10432: [Trivial] Add BITCOIN_FS_H endif footer in fs.h 2019-06-24 11:39:34 -05:00
hash.cpp
hash.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
hdchain.cpp Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
hdchain.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
httprpc.cpp Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet() 2019-07-11 10:34:46 -05:00
httprpc.h Merge #10568: Remove unnecessary forward class declarations in header files 2019-07-09 13:08:20 -05:00
httpserver.cpp Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet() 2019-07-11 10:34:46 -05:00
httpserver.h Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
indirectmap.h
init.cpp Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet() 2019-07-11 10:34:46 -05:00
init.h
keepass.cpp Scripted diff find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g' based on bb81e17355 2019-06-24 12:03:00 -05:00
keepass.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
key.cpp Merge #10075: Remove unused C++ code not covered by unit tests 2019-06-14 14:47:39 -05:00
key.h Merge #10075: Remove unused C++ code not covered by unit tests 2019-06-14 14:47:39 -05:00
keystore.cpp Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
keystore.h Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
limitedmap.h Collection of minor performance optimizations (#2855) 2019-04-11 15:42:14 +03:00
Makefile.am Merge #10544: Update to LevelDB 1.20 2019-07-09 13:08:20 -05:00
Makefile.bench.include Merge #10544: Update to LevelDB 1.20 2019-07-09 13:08:20 -05:00
Makefile.leveldb.include Merge #10544: Update to LevelDB 1.20 2019-07-09 13:08:20 -05:00
Makefile.qt.include Merge #10544: Update to LevelDB 1.20 2019-07-09 13:08:20 -05:00
Makefile.qttest.include Merge #10295: [qt] Move some WalletModel functions into CWallet 2019-07-11 10:34:46 -05:00
Makefile.test.include Merge #10544: Update to LevelDB 1.20 2019-07-09 13:08:20 -05:00
memusage.h Merge #10548: Use std::unordered_{map,set} (C++11) instead of boost::unordered_{map,set} 2019-07-08 10:24:29 -05:00
merkleblock.cpp Do not skip pushing of vMatch and vHashes in CMerkleBlock (#2826) 2019-04-04 08:11:04 +02:00
merkleblock.h
messagesigner.cpp Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
messagesigner.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
miner.cpp scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
miner.h Merge #10568: Remove unnecessary forward class declarations in header files 2019-07-09 13:08:20 -05:00
net_processing.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
net_processing.h Merge #9725: CValidationInterface Cleanups 2019-05-27 09:03:19 -05:00
net.cpp Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet() 2019-07-11 10:34:46 -05:00
net.h Merge #10496: Add Binds, WhiteBinds, Whitelistedrange to CConnman::Options 2019-07-11 10:34:46 -05:00
netaddress.cpp Merge #10446: net: avoid extra dns query per seed 2019-07-11 10:34:46 -05:00
netaddress.h Merge #10446: net: avoid extra dns query per seed 2019-07-11 10:34:46 -05:00
netbase.cpp Merge #10446: net: avoid extra dns query per seed 2019-07-11 10:34:46 -05:00
netbase.h Merge #10061: [net] Added SetSocketNoDelay() utility function 2019-06-24 11:39:34 -05:00
netfulfilledman.cpp Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
netfulfilledman.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
netmessagemaker.h
noui.cpp
noui.h
pow.cpp
pow.h
prevector.h Merge #10534: Clarify prevector::erase and avoid swap-to-clear 2019-07-09 13:08:20 -05:00
protocol.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
protocol.h Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
pubkey.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
pubkey.h
random.cpp Merge #10614: random: fix crash on some 64bit platforms 2019-07-09 13:08:21 -05:00
random.h Merge #10377: Use rdrand as entropy source on supported platforms 2019-07-09 13:08:21 -05:00
rest.cpp Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
reverselock.h
saltedhasher.cpp
saltedhasher.h
scheduler.cpp Merge #10372: Add perf counter data to GetStrongRandBytes state in scheduler 2019-06-24 11:39:34 -05:00
scheduler.h Merge #10395: Replace boost::function with std::function (C++11) 2019-06-24 11:39:34 -05:00
serialize.h Fix compiler warning (#2956) 2019-05-30 11:00:31 +03:00
spentindex.h Optimize on-disk deterministic masternode storage to reduce size of evodb (#3017) 2019-07-09 08:59:57 +03:00
spork.cpp Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
spork.h Remove legacy InstantSend code (#3020) 2019-07-09 17:50:08 +03:00
stacktraces.cpp Enable stacktrace support in gitian builds (#3006) 2019-07-02 07:16:11 +03:00
stacktraces.h Enable stacktrace support in gitian builds (#3006) 2019-07-02 07:16:11 +03:00
streams.h Merge #9911: Wshadow: various gcc fixes 2019-05-06 14:51:45 -05:00
sync.cpp scripted-diff: Remove PAIRTYPE #10502 2019-07-09 13:08:21 -05:00
sync.h Merge #10546: Remove 33 unused Boost includes 2019-07-08 13:50:05 -05:00
threadinterrupt.cpp
threadinterrupt.h
threadsafety.h
timedata.cpp scripted diff: #10502 Fully remove BOOST_FOREACH 2019-07-09 13:08:21 -05:00
timedata.h
tinyformat.h Merge bitcoin#9963: util: Properly handle errors during log message formatting (#2917) 2019-05-21 15:32:33 +02:00
torcontrol.cpp Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
torcontrol.h
txdb.cpp Merge #9176: Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() 2019-07-11 10:34:46 -05:00
txdb.h Merge #9176: Globals: Pass Consensus::Params through CBlockTreeDB::LoadBlockIndexGuts() 2019-07-11 10:34:46 -05:00
txmempool.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
txmempool.h Merge #10568: Remove unnecessary forward class declarations in header files 2019-07-09 13:08:20 -05:00
ui_interface.cpp
ui_interface.h Merge #10568: Remove unnecessary forward class declarations in header files 2019-07-09 13:08:20 -05:00
uint256.cpp
uint256.h Update copyright date (2019) (#2970) 2019-06-11 14:46:07 +03:00
undo.h
unordered_lru_cache.h Replace BITCOIN_UNORDERED_LRU_CACHE_H with DASH_UNORDERED_LRU_CACHE_H 2019-03-11 15:18:25 +01:00
util.cpp Merge #10118: Util: Remove redundant calls to argsGlobal.IsArgSet() 2019-07-11 10:34:46 -05:00
util.h Merge #10400: [RPC] Add an uptime command that displays the amount of time (in seconds) bitcoind has been running 2019-07-11 10:34:46 -05:00
utilmoneystr.cpp
utilmoneystr.h
utilstrencodings.cpp Merge #10633: doc: Fix various typos 2019-07-11 10:34:46 -05:00
utilstrencodings.h scripted-diff: Remove PAIRTYPE #10502 2019-07-09 13:08:21 -05:00
utiltime.cpp Revert " Add real timestamp to log output when mock time is enabled (#2604)" 2019-06-24 11:39:34 -05:00
utiltime.h Revert " Add real timestamp to log output when mock time is enabled (#2604)" 2019-06-24 11:39:34 -05:00
validation.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
validation.h Merge #10503: Use REJECT_DUPLICATE for already known and conflicted txn 2019-07-09 13:09:21 -05:00
validationinterface.cpp Remove CValidationInterface::UpdatedTransaction 2019-06-14 01:25:32 -05:00
validationinterface.h Remove CValidationInterface::UpdatedTransaction 2019-06-14 01:25:32 -05:00
version.h Merge #10560: Remove unused constants 2019-07-08 13:50:05 -05:00
versionbits.cpp Merge #9544: [trivial] Add end of namespace comments. Improve consistency. 2019-07-11 10:34:46 -05:00
versionbits.h Merge #10463: Names: BIP9 vs versionbits 2019-07-08 10:23:19 -05:00
warnings.cpp Scripted diff find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g' based on bb81e17355 2019-06-24 12:03:00 -05:00
warnings.h