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 an infinite loop in new context #12402

Merged
merged 2 commits into from
Mar 20, 2018
Merged

Fix an infinite loop in new context #12402

merged 2 commits into from
Mar 20, 2018

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Mar 19, 2018

Fixes #12389.

The issue was caused by top-level .return pointer not getting updated before descending. Then this condition would never be true and we'd loop forever.

It doesn't affect other cases because we update .return in the loop. The top-level parent is just outside of the loop.

We set .return pointer inside the loop, but the top-level parent-child relationship happens outside.

This ensures the top-level parent's child points to the right copy of the parent.

Otherwise we may end up in a situation where (workInProgress === nextFiber) is never true and we loop forever.
@gaearon gaearon changed the title Add a regression test for the context infinite loop Fix the infinite loop in new context Mar 19, 2018
@gaearon gaearon changed the title Fix the infinite loop in new context Fix an infinite loop in new context Mar 19, 2018
@facebook facebook deleted a comment from pull-bot Mar 19, 2018
@gaearon gaearon requested review from bvaughn and acdlite March 19, 2018 20:56
@gaearon gaearon merged commit 8d09422 into facebook:master Mar 20, 2018
LeonYuAng3NT pushed a commit to LeonYuAng3NT/react that referenced this pull request Mar 22, 2018
* Add a regression test for the context infinite loop

* Fix the bug

We set .return pointer inside the loop, but the top-level parent-child relationship happens outside.

This ensures the top-level parent's child points to the right copy of the parent.

Otherwise we may end up in a situation where (workInProgress === nextFiber) is never true and we loop forever.
rhagigi pushed a commit to rhagigi/react that referenced this pull request Apr 19, 2018
* Add a regression test for the context infinite loop

* Fix the bug

We set .return pointer inside the loop, but the top-level parent-child relationship happens outside.

This ensures the top-level parent's child points to the right copy of the parent.

Otherwise we may end up in a situation where (workInProgress === nextFiber) is never true and we loop forever.
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.

3 participants