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

SHAMap::snapShot maybe exist an error #3020

Closed
NewChinese opened this issue Aug 2, 2019 · 2 comments
Closed

SHAMap::snapShot maybe exist an error #3020

NewChinese opened this issue Aug 2, 2019 · 2 comments
Assignees
Labels

Comments

@NewChinese
Copy link

std::shared_ptr
SHAMap::snapShot (bool isMutable) const
{
auto ret = std::make_shared (type_, f_, get_version());
SHAMap& newMap = *ret;

if (!isMutable)
    newMap.state_ = SHAMapState::Immutable;

newMap.seq_ = seq_ + 1;
newMap.ledgerSeq_ = ledgerSeq_;
newMap.root_ = root_;
newMap.backed_ = backed_;

**if ((state_ != SHAMapState::Immutable) || !isMutable)**
{
    // If either map may change, they cannot share nodes
    newMap.unshare ();
}

return ret;

}

In the above codes, this line "if ((state_ != SHAMapState::Immutable) || !isMutable)" ,
it seems that it should be "if ((state_ != SHAMapState::Immutable) || isMutable)"

HowardHinnant added a commit to HowardHinnant/rippled that referenced this issue Aug 8, 2019
@HowardHinnant HowardHinnant self-assigned this Aug 8, 2019
@HowardHinnant
Copy link
Contributor

Thanks for submitting this issue!

@JoelKatz
Copy link
Collaborator

JoelKatz commented Aug 9, 2019

The code does look wrong. I think it's not hurting us because I don't believe the code ever tries to take a mutable snapshot of a ledger that isn't already unshared. But I suspect it would be possible to create a unit test that fails with the current code and works correctly with this fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants