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

[BUG] memory leak in fast_vector::move_back #15

Open
constroy opened this issue Nov 25, 2021 · 1 comment
Open

[BUG] memory leak in fast_vector::move_back #15

constroy opened this issue Nov 25, 2021 · 1 comment

Comments

@constroy
Copy link
Collaborator

constroy commented Nov 25, 2021

Here we construct a new object in-place.

https://github.com/open-mmlab/CLUE/blob/6c2f4707e564dbc53d616eb70f6a913a42552941/include/clue/fast_vector.hpp#L78

But we forget to destroy the object *dst that is already in this place.
So some object with non-trivial destructor will fail to clean up.
e.g. std::shared_ptr.

@constroy
Copy link
Collaborator Author

constroy commented Nov 26, 2021

For a general vector implementation, we shall not rely on the behavior of the element's move constructor.
Because sometimes the move constructor is not implemented and falls back to the copy constructor.
In that case, the element in dst is never moved or destroyed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant