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

Guard against seg fault if replaceChild index is out of bounds #1744

Closed
wants to merge 1 commit into from

Conversation

joevilches
Copy link
Contributor

Summary:
We are seeing some seg faults after the new display: contents logic was added. This is either because we are passing in an out of bounds index - in which case we try to read display_ from protected memory. Or, the Node * was deleted at some point without removing it from this array. I think its the out of bounds issue mainly because I am not sure where this deletion would occur

I added an if to revert to the legacy, undefined behavior in this case. This is not ideal and we should find the root cause that is calling into this function improperly but for now it stops apps from crashing on the replaceChild call

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D66038645

Copy link

vercel bot commented Nov 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yoga-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2024 8:02pm

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D66038645

joevilches added a commit to joevilches/yoga that referenced this pull request Nov 16, 2024
…ook#1744)

Summary:

X-link: facebook/react-native#47644

We are seeing some seg faults after the new display: contents logic was added. This is either because we are passing in an out of bounds index - in which case we try to read `display_` from protected memory. Or, the `Node *` was deleted at some point without removing it from this array. I think its the out of bounds issue mainly because I am not sure where this deletion would occur

I added an if to revert to the legacy, undefined behavior in this case. This is not ideal and we should find the root cause that is calling into this function improperly but for now it stops apps from crashing on the `replaceChild` call

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D66038645
joevilches added a commit to joevilches/react-native that referenced this pull request Nov 16, 2024
…ook#47644)

Summary:
X-link: facebook/yoga#1744


We are seeing some seg faults after the new display: contents logic was added. This is either because we are passing in an out of bounds index - in which case we try to read `display_` from protected memory. Or, the `Node *` was deleted at some point without removing it from this array. I think its the out of bounds issue mainly because I am not sure where this deletion would occur

I added an if to revert to the legacy, undefined behavior in this case. This is not ideal and we should find the root cause that is calling into this function improperly but for now it stops apps from crashing on the `replaceChild` call

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D66038645
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D66038645

…ook#1744)

Summary:

X-link: facebook/react-native#47644

We are seeing some seg faults after the new display: contents logic was added. This is either because we are passing in an out of bounds index - in which case we try to read `display_` from protected memory. Or, the `Node *` was deleted at some point without removing it from this array. I think its the out of bounds issue mainly because I am not sure where this deletion would occur

I added an if to revert to the legacy, undefined behavior in this case. This is not ideal and we should find the root cause that is calling into this function improperly but for now it stops apps from crashing on the `replaceChild` call

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D66038645
joevilches added a commit to joevilches/react-native that referenced this pull request Nov 18, 2024
…ook#47644)

Summary:
X-link: facebook/yoga#1744


We are seeing some seg faults after the new display: contents logic was added. This is either because we are passing in an out of bounds index - in which case we try to read `display_` from protected memory. Or, the `Node *` was deleted at some point without removing it from this array. I think its the out of bounds issue mainly because I am not sure where this deletion would occur

I added an if to revert to the legacy, undefined behavior in this case. This is not ideal and we should find the root cause that is calling into this function improperly but for now it stops apps from crashing on the `replaceChild` call

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D66038645
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D66038645

@NickGerleman
Copy link
Contributor

@joevilches how much of an emergency is this? Silently allowing shadowtree or other Yoga node corruption to happen later just moves the blame of the problem, instead of fixing anything. We should be hard asserting here, like we do in some other places by using “at()” instead of subscript operator.

@joevilches
Copy link
Contributor Author

@NickGerleman oh yeah totally with you. This was a stop gap for a UBN, although I think the urgency is lower than I initially thought on Friday. I was putting this out here to at least revert to previous behavior in bad cases with a follow up to actually fix this. We can chat more tomorrow though, I plan on sitting on this change at this point.

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