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 crash when saving resources with circular references #68281

Merged

Conversation

maximkulkin
Copy link
Contributor

@maximkulkin maximkulkin commented Nov 5, 2022

When saving resources, marking of already seen resources was done too late, causing infinite loop traversing referenced resources and eventual stack overflow. The change marks traversed resource before descending to it's children, thus when this resource is encountered again, it is already marked as seen and traversal stops.

Fixes #60590

@maximkulkin maximkulkin requested a review from a team as a code owner November 5, 2022 07:10
@Calinou Calinou added this to the 4.0 milestone Nov 5, 2022
@fire
Copy link
Member

fire commented Dec 27, 2022

Any idea why the build tests are failing?

@maximkulkin maximkulkin requested a review from a team as a code owner February 17, 2023 10:23
@maximkulkin
Copy link
Contributor Author

maximkulkin commented Feb 17, 2023

I have pulled back support for saving circular references as it can cause memory leaks. Instead I narrowed this change down to fixing crash when saving resources with circular references.

@maximkulkin maximkulkin changed the title Allow circular resource references saved into text and binary resource files Fix crash when saving resources with circular references Feb 17, 2023
@akien-mga akien-mga modified the milestones: 4.0, 4.1 Feb 17, 2023
@akien-mga
Copy link
Member

Looks good to me overall, but needs a review from @reduz to make sure it's correct.
As this is sensitive code and fixes a rare problem, we can wait for after the 4.0 release (and cherry-pick the fix to 4.0.x eventually).

@maximkulkin maximkulkin force-pushed the resource-circular-references branch 3 times, most recently from 381035d to f39b9cd Compare February 20, 2023 01:57
@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 19, 2023
Copy link
Member

@RandomShaper RandomShaper left a comment

Choose a reason for hiding this comment

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

To me, looks good to go and be tested in early 4.2 dev releasese.

When saving resources, marking of already seen resources was
done too late, causing infinite loop traversing referenced resources
and eventual stack overflow. The change marks traversed resource
before descending to it's children, thus when this resource is
encountered again, it is already marked as seen and traversal stops.
@YuriSizov YuriSizov force-pushed the resource-circular-references branch from f39b9cd to 058604f Compare July 14, 2023 17:21
@YuriSizov
Copy link
Contributor

I rebased and force-pushed it on your behalf because it's been many months since the last update. Just in case there may be problems or new checks on CI.

@YuriSizov
Copy link
Contributor

Thanks!

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.

Segmentation fault when setting exported value to self in imported resource
6 participants