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

Make CowData self-inserts safe #34266

Closed

Conversation

RandomShaper
Copy link
Member

When inserting an element taking the original from the current data block so that it will be resized, potentially invalidating the reference to the original, a backup is made to base the copy on it instead.

Fixes #31736.

Other related items (fixed, superseded or plainly related): #16961, #29408, #31159, #31609, #31694.

P. S.: Haven't had time to test this thoroughly.

@akien-mga
Copy link
Member

Ah I hadn't noticed that your PR'ed it on the vulkan branch, but it should track master. The vulkan branch is strictly for Vulkan-related changes, I rebase it every once in a while on master.

@RandomShaper
Copy link
Member Author

OK. I'll fix this.

What about changes for 4.0, like C++11 atomics? Is master for 4.0 now?

@akien-mga
Copy link
Member

What about changes for 4.0, like C++11 atomics? Is master for 4.0 now?

Not yet, but soon. For now it's probably best to PR such changes against master for review, and redo them once the vulkan branch is merged.

When inserting an element taking the original from the current data block so that it will be resized, potentially invalidating the reference to the original, a backup is made to base the copy on it instead.

Fixes godotengine#31736.
@akien-mga akien-mga changed the base branch from vulkan to master January 2, 2020 14:48
@akien-mga akien-mga removed cherrypick:3.1 cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jan 2, 2020
@akien-mga
Copy link
Member

For 3.2 we merged #34618 as a simpler stopgap solution, so we'd probably consider that one too for cherry-picking in 3.1.x.

This PR should be reviewed for 4.0. There was a lot of discussion on IRC with @reduz and @hpvb regarding what should be done exactly to solve those issues, which might be worth rediscussing with you.

@reduz
Copy link
Member

reduz commented Feb 10, 2020

IMO I would just close this, the solution is bigger than the problem. As I mentioned in the existing fix, the drawbacks of just copying the value are next to none in real life scenarios.

@RandomShaper RandomShaper deleted the fix_vector_self_insert branch February 10, 2020 12:15
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.

push_back / insert vector element into the same vector
3 participants