Skip to content

Conversation

@luke-jr
Copy link
Member

@luke-jr luke-jr commented Sep 20, 2022

cs_desc_main is typically locked within scope of a cs_wallet lock, but:

CWallet::IsLocked locks cs_wallet
...called from DescriptorScriptPubKeyMan::GetKeys
...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first


Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by #26082 (CI fails as a result)

cs_desc_main is typically locked within scope of a cs_wallet lock, but:

CWallet::IsLocked locks cs_wallet
...called from DescriptorScriptPubKeyMan::GetKeys
...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet
...called from DescriptorScriptPubKeyMan::SignMessage
...called from CWallet::SignMessage which can access and lock cs_wallet

Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first
@luke-jr
Copy link
Member Author

luke-jr commented Sep 20, 2022

(It would be good to have someone more familiar with descriptor wallet code take a look if there's a better way to fix this.)

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 20, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24058 (BIP-322 basic support by kallewoof)
  • #16545 (refactor: Implement missing error checking for ArgsManager flags 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.

@achow101
Copy link
Member

ACK a60d9eb

Note that the signmessage RPC does not run into this issue because the RPC function holds cs_wallet prior to calling CWallet::SignMessage.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK a60d9eb

But most CI checks are failing with an unclear message.

@achow101
Copy link
Member

But most CI checks are failing with an unclear message.

I think it needs to be rebased.

@luke-jr
Copy link
Member Author

luke-jr commented Sep 22, 2022

But most CI checks are failing with an unclear message.

This is a CI bug.

Edit: To be more specific, it looks like the CI infra is handling it okay, but some older CI distros have a very old version of git that can't handle the merge.

@DrahtBot DrahtBot mentioned this pull request Sep 22, 2022
@fanquake
Copy link
Member

but some older CI distros

The majority of the failing jobs are using Ubuntu Focal, which was released 2 years ago, and is LTS for another 3 years.

have a very old version of git

Ubuntu Focal ships with git version 2.25, which was released ~2.5 years ago.

@hebasto
Copy link
Member

hebasto commented Sep 23, 2022

But most CI checks are failing with an unclear message.

I think it needs to be rebased.

... but some older CI distros have a very old version of git that can't handle the merge.

Confirming that rebasing does help.

@glozow glozow added the Wallet label Sep 23, 2022
@luke-jr
Copy link
Member Author

luke-jr commented Sep 23, 2022

Looks like the minimum git to make the merge is 2.33. But the PR itself is fine as-is, and once merged won't be a problem even for old versions of git.

@maflcko maflcko merged commit 0cfbb17 into bitcoin:master Sep 24, 2022
@fanquake fanquake added this to the 24.0 milestone Sep 24, 2022
@fanquake
Copy link
Member

@achow101 are we backporting this for 24.x?

@achow101
Copy link
Member

Yes, for backport

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 25, 2022
a60d9eb Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  cs_desc_main is typically locked within scope of a cs_wallet lock, but:

  CWallet::IsLocked locks cs_wallet
  ...called from DescriptorScriptPubKeyMan::GetKeys
  ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

  Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first

  -------------

  Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by bitcoin#26082 (CI fails as a result)

ACKs for top commit:
  achow101:
    ACK a60d9eb
  w0xlt:
    ACK bitcoin@a60d9eb

Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
maflcko pushed a commit that referenced this pull request Sep 25, 2022
a60d9eb Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  (Clean merge of #26130 to 24.x branch)

Top commit has no ACKs.

Tree-SHA512: 821e19d222cc1eb9a6b957ec87d48cfb00b2c5b8182682ac57d9c76785b667ad9c71444e6bf0f53177c06d5fb39e72dbfc82d7debe4b1597699eefaf3001d08d
@fanquake
Copy link
Member

Backported to 24.x in #26178.

@hebasto
Copy link
Member

hebasto commented Sep 27, 2022

Looks like the minimum git to make the merge is 2.33. But the PR itself is fine as-is, and once merged won't be a problem even for old versions of git.

It appears, it is a problem as now the CI linter job fails.

@luke-jr
Copy link
Member Author

luke-jr commented Sep 28, 2022

It appears, it is a problem as now the CI linter job fails.

??? Looks like it's working fine to me? https://cirrus-ci.com/build/5775460305993728

@hebasto
Copy link
Member

hebasto commented Sep 28, 2022

It appears, it is a problem as now the CI linter job fails.

??? Looks like it's working fine to me? https://cirrus-ci.com/build/5775460305993728

Don't hesitate to look into the following merge commits:

Merge commit 0cfbb171bd6f61a4edba913e281553b9bdf08d4a is not clean
Merge commit 0cfbb171bd6f61a4edba913e281553b9bdf08d4a is not clean

@luke-jr
Copy link
Member Author

luke-jr commented Sep 28, 2022

Looks like an issue with verify-commits. Not sure what the best way to fix that is.

maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Sep 29, 2022
d8ded8b ci: Use git2.34 for lint task (MacroFake)

Pull request description:

  Since most maintainers use a recent version of git that uses the `ort` strategy by default (https://git-scm.com/docs/merge-strategies/2.34.0), bump git for the lint taks as well.

  Fixes bitcoin/bitcoin#26130 (comment)

ACKs for top commit:
  fanquake:
    ACK d8ded8b - seems fine for now, and to keep python3.6 around. When we bump to >= Jammy in future we'll have to pick from Python3.10+.

Tree-SHA512: 5a9c40b1c242678a7f92e641db026309b3e2e99d7d032778c98eeb56f7abd65f9e0a24f9b2ccf0350d5c0286d50f1ac5969e4249beaa5ffc4b00d06ca8b141bc
@bitcoin bitcoin locked and limited conversation to collaborators Sep 28, 2023
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 13, 2025
d8ded8b ci: Use git2.34 for lint task (MacroFake)

Pull request description:

  Since most maintainers use a recent version of git that uses the `ort` strategy by default (https://git-scm.com/docs/merge-strategies/2.34.0), bump git for the lint taks as well.

  Fixes bitcoin#26130 (comment)

ACKs for top commit:
  fanquake:
    ACK d8ded8b - seems fine for now, and to keep python3.6 around. When we bump to >= Jammy in future we'll have to pick from Python3.10+.

Tree-SHA512: 5a9c40b1c242678a7f92e641db026309b3e2e99d7d032778c98eeb56f7abd65f9e0a24f9b2ccf0350d5c0286d50f1ac5969e4249beaa5ffc4b00d06ca8b141bc
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants