Skip to content

[pull] master from facebook:master#83

Merged
pull[bot] merged 1 commit intoloot-king:masterfrom
facebook:master
May 21, 2020
Merged

[pull] master from facebook:master#83
pull[bot] merged 1 commit intoloot-king:masterfrom
facebook:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented May 21, 2020

See Commits and Changes for more details.


Created by pull[bot]. Want to support this open source service? Please star it : )

Summary:
Changelog: [Internal]

# Problem
Yoga internally uses address of owner to determine whether a node should be cloned or it shouldn't.
During layout, it traverses the tree and looks whether current parent is equal to child's owner. If it isn't it means the yoga node is shared between 2+ trees and need to be cloned before mutated. Parent in yoga is stored as reference to the parent.

We can run into an issue where yoga node is shared between 2+ trees, but its current parent is equal to child's owner. This is because we reallocate new parent at address where its previous parent lived. This happens over few iterations, the old parent is first deallocated.

This is known as ABA problem.

# Solution

When we are cloning node, we loop over all children to see whether any of the is not using address of new `yogaNode_` as its owner. At this point we know this is accidental and set its owner to `0xBADC0FFEE0DDF00D`.

We chose `0xBADC0FFEE0DDF00D` because when someone is debugging this in LLDB and prints this address, it will hint them that it was artificially set and can string search for it in the codebase.

Reviewed By: shergin

Differential Revision: D21641096

fbshipit-source-id: c8b1b4487ea02b367f5831c1cdac055bce79c856
@pull pull bot added the ⤵️ pull label May 21, 2020
@pull pull bot merged commit 745ff10 into loot-king:master May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant