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

Bitcoin 0.14 locking PRs #5009

Merged
merged 20 commits into from
Apr 2, 2021
Merged

Conversation

LarryRuane
Copy link
Collaborator

@LarryRuane LarryRuane commented Feb 24, 2021

These are locking changes from upstream (bitcoin core) release 0.14, oldest to newest (when merged to the master branch).

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

@LarryRuane LarryRuane added C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. I-race Problems and improvements related to race conditions. labels Feb 24, 2021
@LarryRuane LarryRuane self-assigned this Feb 24, 2021
@r3ld3v r3ld3v added this to the Core Sprint 2021-06 milestone Feb 25, 2021
@@ -328,8 +335,7 @@ const fs::path GetExportDir()

const fs::path &GetDataDir(bool fNetSpecific)
{

LOCK(csPathCached);
LOCK2(cs_args, csPathCached);
Copy link
Contributor

Choose a reason for hiding this comment

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

Upstream seems to not have included the lock here; but it seems safe to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think it's safe, but also necessary, because this function accesses mapArgs which is protected by cs_args. The upstream commit didn't change this function because it had already been updated to call gArgs.GetArg() (instead of accessing mapArgs directly), and gArgs.GetArg() calls GetSetting(), which acquires cs_args. We probably should pick up these argument-handling changes someday, but that's a big project.

Copy link
Contributor

@str4d str4d Apr 1, 2021

Choose a reason for hiding this comment

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

Yep, I've wanted to get these in for years (and have slowly been unblocking them).

paveljanik and others added 12 commits April 1, 2021 14:29
This makes sure that cs_filter is never held while taking cs_main
or CNode::cs_vSend.

zcash: cherry picked from commit 144ed76
zcash: bitcoin/bitcoin#8606
This removes a "race" between Interrupt() and Run(), though it
should not effect any of our supported platforms.

zcash: cherry picked from commit 7b2d96b
zcash: bitcoin/bitcoin#9679
zcash: cherry picked from commit 9a0b784
zcash: bitcoin/bitcoin#9698
These are (afaik) all long-standing races or concurrent accesses. Going
forward, we can clean these up so that they're not all individual atomic
accesses.

- Reintroduce cs_vRecv to guard receive-specific vars
- Lock vRecv/vSend for CNodeStats
- Make some vars atomic.
- Only set the connection time in CNode's constructor so that it doesn't change

zcash: cherry picked from commit 321d0fc
zcash: bitcoin/bitcoin#9708
zcash: cherry picked from commit 644f123
zcash: bitcoin/bitcoin#9708
@LarryRuane LarryRuane force-pushed the upstream-locking-0.14 branch from b9d7f27 to 7b4fe98 Compare April 1, 2021 21:28
@LarryRuane
Copy link
Collaborator Author

Force-pushed to rebase onto latest master (which now includes #4999).

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK modulo bug

src/net.cpp Outdated Show resolved Hide resolved
TheBlueMatt and others added 8 commits April 2, 2021 12:55
zcash: cherry picked from commit 96f42d8
zcash: bitcoin/bitcoin#9708
zcash: cherry picked from commit 0f31872
zcash: bitcoin/bitcoin#9708
zcash: cherry picked from commit d8f2b8a
zcash: bitcoin/bitcoin#9708
A new AssertLockHeld(cs_wallet) call was added in commit a58370e
"Dedup nTimeFirstKey update logic" (part of PR #9108).

The lock held assertion will fail when loading prexisting wallets files from
before the #9108 merge that have watch-only keys.

zcash: cherry picked from commit 07afcd6
zcash: bitcoin/bitcoin#9771
@str4d str4d force-pushed the upstream-locking-0.14 branch from 7b4fe98 to 4fd7387 Compare April 1, 2021 23:56
Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK. I force-pushed to fix the cherry-pick bug.

@str4d
Copy link
Contributor

str4d commented Apr 1, 2021

@zkbot r+

@zkbot
Copy link
Contributor

zkbot commented Apr 1, 2021

📌 Commit 4fd7387 has been approved by str4d

@zkbot
Copy link
Contributor

zkbot commented Apr 1, 2021

⌛ Testing commit 4fd7387 with merge 1b5f17c900ccb344f3952cf5f10a7cd7a7c48bbb...

@zkbot
Copy link
Contributor

zkbot commented Apr 2, 2021

💔 Test failed - pr-merge

@str4d
Copy link
Contributor

str4d commented Apr 2, 2021

Transient failure.

@zkbot retry

@zkbot
Copy link
Contributor

zkbot commented Apr 2, 2021

⌛ Testing commit 4fd7387 with merge 80e66e7...

@zkbot
Copy link
Contributor

zkbot commented Apr 2, 2021

☀️ Test successful - pr-merge
Approved by: str4d
Pushing 80e66e7 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. I-race Problems and improvements related to race conditions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.