This should be before the line above. Anyway, there is no need to lock this wallet since it's a fresh instance, unknown to the remaining system. Unless you are adding the lock because of other asserts and if so please commit them to justify this change?
practicalswift
commented at 4:08 PM on November 8, 2017:
Now moved before the line above. Without that lock we'll trigger Clang thread safety analysis warnings when #11634 is merged due to:
As agreed upon in #11226 (comment) all guard/lock annotations are added in #11634 and all extra locking is submitted as separate PR:s (such as this one).
The annotations are compile-time only whereas the locks change run-time behaviour (and thus needs extra scrunity!).
As agreed upon in #11226 (comment) all guard/lock annotations are added in #11634 and all extra locking is submitted as separate PR:s (such as this one)
I think you swapped the PR numbers?
practicalswift
commented at 9:55 PM on November 8, 2017:
Yes, you're right - the annotations are added in #11226 :-)
practicalswift force-pushed on Nov 8, 2017
promag
commented at 8:36 PM on November 8, 2017:
member
utACK007fcbf.
luke-jr referenced this in commit a6b3c637e6 on Nov 11, 2017
practicalswift force-pushed on Nov 21, 2017
practicalswift
commented at 4:58 PM on November 21, 2017:
contributor
Added another commit with two more missing locks:
calling function IsSpent requires holding mutex pwallet->cs_wallet exclusively
@TheBlueMatt Moving it further up will make the scope of the walletInstance->cs_wallet lock cover the ScanForWalletTransactions call. ScanForWalletTransactions locks cs_main giving us the lock order:
cs_wallet
cs_main
This is a potential deadlock given that the opposite lock order is used extensively:
practicalswift
commented at 1:27 PM on March 10, 2018:
contributor
@MarcoFalke@TheBlueMatt@promag Thanks for reviewing. I've now addressed the feedback and added corresponding GUARDED_BY/EXCLUSIVE_LOCKS_REQUIRED annotations. Please re-review :-)
in
src/wallet/wallet.cpp:3900
in
8dcfcb265doutdated
MarcoFalke
commented at 10:12 PM on March 11, 2018:
Note that LoadWallet takes LOCK2(cs_main, cs_wallet), so taking cs_wallet before cs_main leads to a deadlock in case another thread takes cs_main and then cs_wallet, no?
@promag I think I'm unable to resolve this. Are you able to make this work with EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) on CWalletTx::GetAvailableCredit when compiling with Clang's thread-safety analysis enabled?
MarcoFalke
commented at 1:10 PM on August 13, 2018:
Agree with @promag . We wouldn't want to add LOCKs just to please a static analyser that isn't smart enough to figure out the lock is already taken.
in
src/wallet/wallet.cpp:1990
in
ce156e6653outdated
@promag See above. In theory you're right, but I've been unable to convince Clang's thread-safety analysis that so is the case in practice. See comment above. I might need some help here :-)
sipa
commented at 12:49 AM on March 15, 2018:
member
Concept ACK
practicalswift force-pushed on Mar 23, 2018
practicalswift force-pushed on Mar 29, 2018
practicalswift force-pushed on Apr 9, 2018
practicalswift force-pushed on Apr 9, 2018
practicalswift
commented at 1:22 PM on April 9, 2018:
contributor
Rebased!
in
src/wallet/wallet.h:711
in
83d2186da4outdated
707 | @@ -708,7 +708,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
708 | int64_t m_max_keypool_index = 0;
709 | std::map<CKeyID, int64_t> m_pool_key_to_index;
710 |
711 | - int64_t nTimeFirstKey = 0; 712 | + int64_t nTimeFirstKey GUARDED_BY(cs_wallet);
In file included from wallet/feebumper.cpp:6:
In file included from ./wallet/coincontrol.h:11:
./wallet/wallet.h:496:76: error: member access into incomplete type 'const CWallet'
std::set<uint256> GetConflicts() const EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet);
^
wallet/wallet.cpp:1874:27: error: calling function 'GetConflicts' requires holding mutex 'pwallet->cs_wallet' exclusively [-Werror,-Wthread-safety-analysis]
result = pwallet->GetConflicts(myHash);
^
practicalswift
commented at 12:53 PM on June 6, 2018:
contributor
@MarcoFalke Another alternative could be to add NO_THREAD_SAFETY_ANALYSIS here to disable the analysis locally.
What would you suggest as the recommended way to proceed?
MarcoFalke
commented at 1:11 PM on June 6, 2018:
member
@practicalswift I like your latest suggestion (NO_THREAD_SAFETY_ANALYSIS). Make sure to include a comment to explain this is only temporary. Also, explain that this is safe to do, since we have a run-time AssertLockHeld in place.
practicalswift force-pushed on Jun 6, 2018
practicalswift force-pushed on Jun 6, 2018
practicalswift force-pushed on Jun 6, 2018
practicalswift force-pushed on Jun 6, 2018
practicalswift force-pushed on Jun 6, 2018
practicalswift
commented at 3:16 PM on June 6, 2018:
contributor
@MarcoFalke Good point! Added and documented NO_THREAD_SAFETY_ANALYSIS. Please review :-)
practicalswift force-pushed on Jul 11, 2018
practicalswift
commented at 11:33 PM on July 11, 2018:
contributor
Rebased!
DrahtBot added the label Needs rebase on Jul 14, 2018
practicalswift force-pushed on Jul 15, 2018
practicalswift force-pushed on Jul 15, 2018
practicalswift
commented at 7:53 AM on July 16, 2018:
contributor
Rebased!
DrahtBot removed the label Needs rebase on Jul 16, 2018
practicalswift force-pushed on Jul 20, 2018
DrahtBot added the label Needs rebase on Jul 24, 2018
practicalswift force-pushed on Aug 1, 2018
practicalswift
commented at 8:33 AM on August 1, 2018:
contributor
Rebased!
DrahtBot removed the label Needs rebase on Aug 1, 2018
practicalswift force-pushed on Aug 6, 2018
practicalswift
commented at 4:16 PM on August 6, 2018:
contributor
Rebased!
practicalswift force-pushed on Aug 13, 2018
practicalswift
commented at 10:47 AM on August 13, 2018:
contributor
Rebase number eight performed! :-)
practicalswift force-pushed on Aug 25, 2018
practicalswift
commented at 10:44 PM on August 25, 2018:
contributor
Rebased!
practicalswift force-pushed on Aug 26, 2018
practicalswift force-pushed on Aug 26, 2018
practicalswift force-pushed on Aug 26, 2018
practicalswift
commented at 3:41 PM on August 26, 2018:
contributor
DrahtBot
commented at 1:30 PM on September 21, 2018:
member
<!--e57a25ab6845829454e8d69fc972939a-->Reviewers, this pull request conflicts with the following ones:
#14498 (rpcwallet: listsentbyaddress RPC by mrwhythat)
#14437 (Refactor: Start to separate wallet from node by ryanofsky)
#14144 (Refactoring: Clarify code using encrypted_batch in CWallet by domob1812)
#13756 (wallet: -avoidreuse feature for improved privacy by kallewoof)
#9381 (Remove CWalletTx merging logic from AddToWallet by ryanofsky)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Add GUARDED_BY(cs_wallet) for encrypted_batch, nWalletMaxVersion, m_max_keypool_index and nOrderPosNext
* AddKeyPubKeyWithDB(...) reads encrypted_batch which potentially races with write in the same method.
* IncOrderPosNext(...) reads nOrderPosNext which potentially races with write in BlockDisconnected(...).
* LoadKeyPool(...) reads m_max_keypool_index which potentially races with write in BlockDisconnected(...).
* LoadMinVersion(...) reads nWalletMaxVersion which potentially races with write in BlockDisconnected(...).
37b2538c2d
practicalswift force-pushed on Oct 9, 2018
practicalswift
commented at 10:19 AM on October 9, 2018:
contributor
Updated!
Added GUARDED_BY(cs_wallet) annotations also for encrypted_batch, nWalletMaxVersion, m_max_keypool_index and nOrderPosNext.
Rationale:
AddKeyPubKeyWithDB(...) reads encrypted_batch which potentially races with write in the same method
IncOrderPosNext(...) reads nOrderPosNext which potentially races with write in BlockDisconnected(...)
LoadKeyPool(...) reads m_max_keypool_index which potentially races with write in BlockDisconnected(...)
LoadMinVersion(...) reads nWalletMaxVersion which potentially races with write in BlockDisconnected(...)
Please review :-)
practicalswift
commented at 12:00 PM on October 9, 2018:
contributor
Added GUARDED_BY(cs_wallet) for setExternalKeyPool, mapKeyMetadata, m_script_metadata and setLockedCoins.
I think that currently there is no harm in calling uiInterface.LoadWallet() with the lock held but if it's not necessary then I wouldn't change that. The diff looks ok.
promag
commented at 9:09 AM on October 24, 2018:
member
utACK69e7ee2.
LarryRuane referenced this in commit e1c6c472e9 on Apr 5, 2021
LarryRuane referenced this in commit d5439c7386 on Apr 5, 2021
LarryRuane referenced this in commit affdf23507 on Apr 5, 2021
LarryRuane referenced this in commit ed497c99af on Apr 5, 2021
practicalswift deleted the branch on Apr 10, 2021
LarryRuane referenced this in commit b2cdcd07c1 on Apr 29, 2021
LarryRuane referenced this in commit a0df9acb00 on Apr 29, 2021
LarryRuane referenced this in commit 10f07f2ad1 on Apr 29, 2021
LarryRuane referenced this in commit 973d009148 on Apr 29, 2021
LarryRuane referenced this in commit 20ce9cce7e on Jun 1, 2021
LarryRuane referenced this in commit 12a307c6e1 on Jun 1, 2021
LarryRuane referenced this in commit 96b1669b6d on Jun 1, 2021
LarryRuane referenced this in commit 4bae811116 on Jun 1, 2021
PastaPastaPasta referenced this in commit dab5cfb8ca on Jul 17, 2021
gades referenced this in commit a188a9ea87 on May 31, 2022
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-21 09:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me