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

may be a code bug #3112

Closed
jerousrb opened this issue Nov 2, 2017 · 2 comments
Closed

may be a code bug #3112

jerousrb opened this issue Nov 2, 2017 · 2 comments
Assignees

Comments

@jerousrb
Copy link

jerousrb commented Nov 2, 2017

in the file db/column_family.cc ,the destructor of ColumnFamilySet, deleting cfd directly after dereferencing by call cfd->Unref();

I think we can delete cfd only when the cfd->Unref()== true, others we no need to delete!

ColumnFamilySet::~ColumnFamilySet() {
while (column_family_data_.size() > 0) {
// cfd destructor will delete itself from column_family_data_
auto cfd = column_family_data_.begin()->second;
cfd->Unref();
delete cfd; // this should do it when cfd->Unref()==true ?
}
dummy_cfd_->Unref();
delete dummy_cfd_;
}

@ajkr
Copy link
Contributor

ajkr commented Nov 2, 2017

Interesting question. The ColumnFamilySet is deleted only when the DB is destroyed, so maybe this lets us avoid memory leak in case there are CFD referrers that forget to call Unref(). Want to try fixing it as you suggested and see if valgrind/ASAN pass?

@yiwu-arbug
Copy link
Contributor

I think an assert is more appropriate since cfd is not suppose to outlive the DB. I'll send a patch.

amytai pushed a commit to amytai/rocksdb that referenced this issue Mar 9, 2018
Summary:
In ColumnFamilySet destructor, assert it hold the last reference to cfd before destroy them.

Closes facebook#3112
Closes facebook#3397

Differential Revision: D6777967

Pulled By: yiwu-arbug

fbshipit-source-id: 60b19070e0c194b3b6146699140c1d68777866cb
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

3 participants