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

Revert regression of memory unsafe append_array (same vector into same vector). #101386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ivorforce
Copy link
Contributor

Follow-up of #101385

This will cause a minor performance regression. But Vector is CoW so it won't be noticeable (and probably not even observable).

See #31736.

@Ivorforce Ivorforce requested a review from a team as a code owner January 10, 2025 11:21
@AThousandShips AThousandShips added this to the 4.4 milestone Jan 10, 2025
@lawnjelly
Copy link
Member

lawnjelly commented Jan 10, 2025

#31736 was a great issue, I have to commend the author.

I've since been guilty of exactly this mistake myself (in LocalVector::erase_multiple_unordered(), it's a really easy thing to overlook. I suspect there's a lot of const T & in the containers that could do with reviewing for this bug.

Incidentally, for things like append in the long run, it could be worth checking for within the vector to avoid making a copy, because the benefits to doing the "check within" were higher the larger the size of the object being copied. As you say, here, COW might mostly negate this cost luckily.

@akien-mga
Copy link
Member

akien-mga commented Jan 10, 2025

I would amend #101385 into this PR's commit, it seems weird for #101385 to add comments for 3 cases and leave it to another PR to add the comment to the 4th case.

And add more exhaustive docs while fixing a regression to prevent such regressions in the future makes sense to me semantically.

@akien-mga akien-mga changed the title Revert regression of memory unsafe append_array (same vector into same vector). Revert regression of memory unsafe append_array (same vector into same vector). Jan 10, 2025
core/templates/vector.h Outdated Show resolved Hide resolved
@akien-mga
Copy link
Member

For the record this was changed in #86966 (CC @Muller-Castro).
Might be worth re-reviewing that PR and its open follow-ups with #31736 in mind.

@Ivorforce
Copy link
Contributor Author

Ivorforce commented Jan 10, 2025

I would amend #101385 into this PR's commit, it seems weird for #101385 to add comments for 3 cases and leave it to another PR to add the comment to the 4th case.

And add more exhaustive docs while fixing a regression to prevent such regressions in the future makes sense to me semantically.

I did it this way because I like to have separate no-op commits (like adding docs) and behavior change commits. But I'm happy to oblige if you'd prefer to have it all in one.

Edit: Done!

… (append vector to itself). Add comments to prevent future regressions.
@Muller-Castro
Copy link
Contributor

Hello! 🤝 should I rollback the Vector<T> params?

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.

5 participants