Skip to content

[primitives, consensus] Make fChecked an atomic<bool> - #14072

Closed
skeees wants to merge 1 commit into
bitcoin:masterfrom
skeees:fchecked-atomic
Closed

skeees wants to merge 1 commit into
bitcoin:masterfrom
skeees:fchecked-atomic

Conversation

@skeees

@skeees skeees commented Aug 26, 2018

Copy link
Copy Markdown
Contributor

This addresses a data race / thread sanitizer issue uncovered in #14058

If there are alternate suggestions about how to effectuate this change in a more compact way without having to manually declare the copy constructor and copy assignment operator (because it is deleted for std::atomic<bool> that feedback would be welcome).

CheckBlock can be invoked from multiple threads in parallel. To avoid
a data race, fChecked should be atomic. In practice, this would have
had limited effect currently since these paths are effectively
single-threaded in practice, except to maybe occasionally cause a
slight bit of redundant work to be performed in CheckBlock.

CheckBlock can be invoked from multiple threads in parallel. To avoid
a data race, fChecked should be atomic. In practice, this would have
had limited effect currently since these paths are effectively
single-threaded in practice, except to maybe occasionally cause a
slight bit of redundant work to be performed in CheckBlock.
@DrahtBot

DrahtBot commented Aug 26, 2018 •

Copy link
Copy Markdown
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #10785 (Serialization improvements by sipa)

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.

Comment thread src/primitives/block.h
:CBlock(static_cast<CBlockHeader>(block))
{
vtx = block.vtx;
fChecked = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason to set this to false when copying?

nit: Also, could rename the member to m_checked, since it is only used in one function on master.

Comment thread src/primitives/block.h
CBlock(const CBlock &block)
:CBlock(static_cast<CBlockHeader>(block))
{
vtx = block.vtx;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perform initialization in initialization list instead :-)

Comment thread src/primitives/block.h
:CBlock(static_cast<CBlockHeader>(block))
{
vtx = block.vtx;
fChecked = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perform initialization in initialization list instead :-)

@laanwj

laanwj commented Nov 23, 2018

Copy link
Copy Markdown
Member

Concept ACK

@maflcko

maflcko commented Nov 23, 2018

Copy link
Copy Markdown
Member

Could remove the tsan suppression for fChecked after a rebase.

@fanquake

Copy link
Copy Markdown
Member

Closing in favour of #14803.

@fanquake fanquake closed this Nov 25, 2018
laanwj added a commit that referenced this pull request Dec 1, 2018
c5ed6e7 Move CheckBlock() call to critical section (Hennadii Stepanov)

Pull request description:

  This is an alternative to #14803.

  Refs:
  - #14058
  - #14072
  - #14803 (comment) by @gmaxwell
  > It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

  - #14803 (comment) by @MarcoFalke

Tree-SHA512: 2152e97106e11da5763b2748234ecd2982daadab13a0da04215f4db60af802a44ab5700f32249137d122eb13fc2a02e0f2d561d364607d727d8c6ab879339afb
vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Sep 6, 2021
…ction

c5ed6e7 Move CheckBlock() call to critical section (Hennadii Stepanov)

Pull request description:

  This is an alternative to bitcoin#14803.

  Refs:
  - bitcoin#14058
  - bitcoin#14072
  - bitcoin#14803 (comment) by @gmaxwell
  > It doesn't support multithreaded validation and there are lot of things that prevent that, which is why I was concerned. Why doesn't the lock on the block index or even cs main prevent concurrency here?

  - bitcoin#14803 (comment) by @MarcoFalke

Tree-SHA512: 2152e97106e11da5763b2748234ecd2982daadab13a0da04215f4db60af802a44ab5700f32249137d122eb13fc2a02e0f2d561d364607d727d8c6ab879339afb
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants