aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-03-13 20:15:07 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-03-13 20:15:09 -0400
commit18462960c0f13bd07d8f52b61e7d7bc17e991eea (patch)
treea6912c605375e83ab1e72194add339ddc12d9b6d
parent0630974647dacaf25e7fcb7f9cbb785bb078ede6 (diff)
parent33eb9071b98e63fd66c1211254e420535320eebd (diff)
downloadbitcoin-18462960c0f13bd07d8f52b61e7d7bc17e991eea.tar.xz
Merge #12681: Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDER
33eb9071b9 Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDER (Russell Yanofsky) Pull request description: Failure looks like: ``` Entering test case "ComputeTimeSmart" test_bitcoin: sync.cpp:100: void potential_deadlock_detected(const std::pair<void*, void*>&, const LockStack&, const LockStack&): Assertion `false' failed. unknown location(0): fatal error in "ComputeTimeSmart": signal: SIGABRT (application abort requested) wallet/test/wallet_tests.cpp(566): last checkpoint ``` Reproducible with: ``` ./configure --enable-debug make -C src test/test_bitcoin && src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ComputeTimeSmart ``` Seems to be caused by acquiring `cs_main` inside `CWallet::ComputeTimeSmart` in #11041. I think this may be causing timeouts on travis like: https://travis-ci.org/bitcoin/bitcoin/jobs/353005676#L2692 Tree-SHA512: b263cd122ea9c88204d1d8e7e35291c71ea6319f05114c5009235a75dbd0f669bc0394f44afeed0d9eb08c2a956cd7c08f1ac4ef28616932fef9b43eaac5521b
-rw-r--r--src/wallet/test/wallet_tests.cpp5
-rw-r--r--src/wallet/wallet.cpp7
2 files changed, 5 insertions, 7 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index 41348b50a4..6e20f8170d 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -553,7 +553,10 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64
if (block) {
wtx.SetMerkleBranch(block, 0);
}
- wallet.AddToWallet(wtx);
+ {
+ LOCK(cs_main);
+ wallet.AddToWallet(wtx);
+ }
LOCK(wallet.cs_wallet);
return wallet.mapWallet.at(wtx.GetHash()).nTimeSmart;
}
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index e1f940e114..3e77daf0bf 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3813,12 +3813,7 @@ unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
{
unsigned int nTimeSmart = wtx.nTimeReceived;
if (!wtx.hashUnset()) {
- const CBlockIndex* pindex = nullptr;
- {
- LOCK(cs_main);
- pindex = LookupBlockIndex(wtx.hashBlock);
- }
- if (pindex) {
+ if (const CBlockIndex* pindex = LookupBlockIndex(wtx.hashBlock)) {
int64_t latestNow = wtx.nTimeReceived;
int64_t latestEntry = 0;