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 missing lock to crypter GetKeys() #10916

Merged
merged 2 commits into from Sep 7, 2017
Merged

add missing lock to crypter GetKeys() #10916

merged 2 commits into from Sep 7, 2017

Conversation

benma
Copy link

@benma benma commented Jul 23, 2017

Issue: #10905

First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Marko Bencun added 2 commits July 23, 2017 23:38
Issue: bitcoin#10905

By returning the result, a few useless lines can be removed.

Return-value-optimization means there should be no copy.
@@ -162,28 +162,26 @@ class CCryptoKeyStore : public CBasicKeyStore
{
{
Copy link
Author

Choose a reason for hiding this comment

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

Could this scope level be removed alongside with the return false in the end, or am I missing something about how LOCK works?

Copy link
Contributor

@bytting bytting Jul 23, 2017

Choose a reason for hiding this comment

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

It certainly looks like it. The lock goes out of scope either way, and that last return is unreachable as it stands now

@jonasschnelli
Copy link
Contributor

I guess the setAddress pass by reference was a humble try to keep the memory control on the caller side and have it properly cleaned. But seems not to be done well.

The lock in GetKeys is definitively missing. Also, the IsCrypted() method is sometimes called without the cs_KeyStore so, fUseCrypto should be turned into an atomic.

It was never a problem because – at the moment – GetKeys get only called when holding cs_main/cs_wallet.

utACK fe09b01

@TheBlueMatt
Copy link
Contributor

utACK fe09b01. As @jonasschnelli points out we need to also fix fUseCrypto to either be atomic or under the lock.

@jonasschnelli
Copy link
Contributor

Tested ACK fe09b01
Ready for merge. Another pair of eyes would be good.

@laanwj laanwj merged commit fe09b01 into bitcoin:master Sep 7, 2017
laanwj added a commit that referenced this pull request Sep 7, 2017
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: #10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Sep 23, 2019
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 21, 2019
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 2, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 4, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 4, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 10, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 10, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 10, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
LarryRuane pushed a commit to LarryRuane/zcash that referenced this pull request Apr 13, 2021
Issue: #10905

By returning the result, a few useless lines can be removed.

Return-value-optimization means there should be no copy.

zcash: cherry picked from commit 5cb3da0
zcash: bitcoin/bitcoin#10916
zkbot added a commit to zcash/zcash that referenced this pull request Apr 17, 2021
Bitcoin 0.16 locking PRs

These are locking changes from upstream (bitcoin core) release 0.16 (Aug 14, 2017, to Feb 16, 2018), oldest to newest (when merged to the master branch).

Each commit also includes a reference both to the PR and the upstream commit.

- bitcoin/bitcoin#11126
  - Excludes changes to wallet tests that we don't have.
- bitcoin/bitcoin#10916
  - first commit only; second commit already merged by d9fcc2b
- bitcoin/bitcoin#11107
  - Only the last commit.
- bitcoin/bitcoin#11593
- bitcoin/bitcoin#11585
- bitcoin/bitcoin#11618
- bitcoin/bitcoin#10286
  - Only the third and last commits.
- bitcoin/bitcoin#11870
- bitcoin/bitcoin#12330
- bitcoin/bitcoin#12366
- bitcoin/bitcoin#12368
- bitcoin/bitcoin#12333
  - Only the first commit.
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 30, 2021
fe09b01 add missing lock to crypter GetKeys() (Marko Bencun)
5cb3da0 keystore GetKeys(): return result instead of writing to reference (Marko Bencun)

Pull request description:

  Issue: bitcoin#10905

  First commit makes GetKeys() return the result instead of writing to a reference to remove some useless lines.

Tree-SHA512: bb51255b5a6cf5488c3d5dee89f539d41f0717f018441d120047f877e0a705a133fb3b7a97d1cf8f73b5d2ed93dd2dbdfcd6f394e40105af2a12e01d397cb402
@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

5 participants