Skip to content

Bug in PersistentMap equals implementation #218

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

Merged
merged 9 commits into from
Apr 30, 2025

Conversation

DmitryNekrasov
Copy link
Contributor

@DmitryNekrasov DmitryNekrasov commented Apr 29, 2025

In case of repeated mutable key removal in mutableReplaceNode, the same node may be passed as targetNode and newNode (due to the owner match in the mutableCollisionRemoveEntryAtIndex method). However, if this node contains only one value and is not the root, we need to promote it to the top. This check and promotion happen in the updateNodeAtIndex method, so even if the references are equal, this method must be called. However, if promotion is not needed, no extra allocation will be performed, since the nodes have the same owner.

@DmitryNekrasov DmitryNekrasov changed the title Bug in PersistentMap equals implementation #198 Bug in PersistentMap equals implementation Apr 29, 2025
@DmitryNekrasov DmitryNekrasov requested a review from fzhinkin April 29, 2025 10:16
Copy link
Collaborator

@fzhinkin fzhinkin left a comment

Choose a reason for hiding this comment

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

One of the causes of all these problems is that some time ago the decision was made to abstain from canonicalizing the map builder due to an issue with iteration (#73).
Could you please check if there are any other problems left after that and if there are parts that could be simplified now?

@DmitryNekrasov
Copy link
Contributor Author

DmitryNekrasov commented Apr 29, 2025

I have fixed iteration issue in #217 and wrote tests to check it, so now I am completely confident in the correctness of how iterators work while maintaining the tree invariant.

@DmitryNekrasov DmitryNekrasov requested a review from fzhinkin April 30, 2025 09:11
Copy link
Collaborator

@fzhinkin fzhinkin left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fixing it!

@DmitryNekrasov DmitryNekrasov merged commit 5c3af1e into master Apr 30, 2025
1 check passed
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.

2 participants