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 potential leak when reusing PinnableSlice instances. #10166

Closed
wants to merge 1 commit into from

Conversation

mpoeter
Copy link
Contributor

@mpoeter mpoeter commented Jun 14, 2022

PinnableSlice may hold a handle to a cache value which must be released to correctly decrement the ref-counter. However, when PinnableSlice variables are reused, e.g. like this:

PinnableSlice pin_slice;
db.Get("foo", &pin_slice);
db.Get("foo", &pin_slice);

then the second Get simply overwrites the old value in pin_slice and the handle returned by the first Get is not released.

This PR adds Reset calls to the Get/MultiGet calls that accept PinnableSlice arguments to ensure proper cleanup of old values.

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

LGTM. I ran into this API pitfall once before too...

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

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.

None yet

3 participants