Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add harmless missing cs_wallet lock in qt CoinControlDialog #10340

Conversation

TheBlueMatt
Copy link
Contributor

This is only barely a missing lock - to tickle it you have to
delete from mapWallet while populating your coin control dialog.
The only way (AFAIK) to do so is to call removeprunedfunds.

This is only barely a missing lock - to tickle it you have to
delete from mapWallet while populating your coin control dialog.
The only way (AFAIK) to do so is to call removeprunedfunds.
@ryanofsky
Copy link
Contributor

utACK 31b7171

@ryanofsky
Copy link
Contributor

It'd be nice to have a comment attached to cs_wallet saying when the lock needs to be acquired:

mutable CCriticalSection cs_wallet;

Bringing this up because I think at this point if anybody would know how to write such a comment, it would probably be you.

// Quantity
nQuantity++;
{
LOCK2(cs_main, model->wallet->cs_wallet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we avoid this really undesirable layer violation (model->wallet->cs_wallet)? This seems to go in the wrong direction with @ryanofsky approach to form clean layers for later process separation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we avoid this really undesirable layer violation (model->wallet->cs_wallet)?

#10244 stops using CWalletTx pointers in Qt altogether, so I think the layer violation would only be temporary. I think #10340 complements #10244 because it makes sense to fix correctness and safety issues first, and then organize the code around those changes.

@@ -215,8 +215,9 @@ class WalletModel : public QObject

bool getDefaultWalletRbf() const;

CWallet *wallet; // Used to lock cs_wallet for getOutputs/listCoins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh!

@jonasschnelli
Copy link
Contributor

If a non-wallet-model code-part needs to obtain the cs_wallet lock, then we should move the logic-part (that requires the lock) to wallet-model.

@TheBlueMatt
Copy link
Contributor Author

Closing in favor of #10244, which is a much better fix, though larger diff.

@TheBlueMatt TheBlueMatt closed this May 5, 2017
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants