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

Fix data race #1259

Merged
merged 10 commits into from Jul 21, 2020
Merged

Fix data race #1259

merged 10 commits into from Jul 21, 2020

Conversation

Honglei-Cong
Copy link
Member

No description provided.


// clone a new block
newBlk := &Block{}
if err := newBlk.Deserialize(block.Serialize()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks too hacky, adding a new proposalSig field in blockProposalMsg to avoid data race.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. But block signatures needs to be updated, and there'll be data race anyway.
You'll have to add lock to block header, or copy a new one.

Copy link
Contributor

Choose a reason for hiding this comment

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

this update function is called when the blockPool's lock holds, I do not expect there is any data race left.

Copy link
Member Author

Choose a reason for hiding this comment

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

No lock when reading signatures in block header, but signature array in block header must be updated.
Either adding locks for all read operations, or just clone a new one when updating then there'll no write ops to block header?

Copy link
Member Author

Choose a reason for hiding this comment

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

blockpool's lock can not protect block headers in proposal message?

ヽ༼ຈʖ̯ຈ༽ノ

Copy link
Member Author

Choose a reason for hiding this comment

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

updated

@laizy laizy merged commit eb78442 into ontio:master Jul 21, 2020
@Honglei-Cong Honglei-Cong deleted the fixDataRace branch July 21, 2020 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants