]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Always iniitalize ArenaWrappedDBIter::db_iter_ to nullptr (#8889)
authorsdong <siying.d@fb.com>
Tue, 14 Sep 2021 21:32:24 +0000 (14:32 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 14 Sep 2021 21:33:15 +0000 (14:33 -0700)
Summary:
ArenaWrappedDBIter::db_iter_ should never be nullptr. However, when debugging a segfault, it's hard to distinguish it is not initialized (not possible) and other corruption. Add this nullptr to help distinguish the case.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8889

Test Plan: Run existing unit tests.

Reviewed By: pdillinger

Differential Revision: D30814756

fbshipit-source-id: 4b1f36896a33dc203d4f1f424ded9554927d61ba

db/arena_wrapped_db_iter.h

index 17273b201d97471267b2500a8de7908038b6de49..cdf9046a9c248882cc5708135cd71f3765bc8975 100644 (file)
@@ -34,7 +34,13 @@ class Version;
 // the same as the inner DBIter.
 class ArenaWrappedDBIter : public Iterator {
  public:
-  virtual ~ArenaWrappedDBIter() { db_iter_->~DBIter(); }
+  virtual ~ArenaWrappedDBIter() {
+    if (db_iter_ != nullptr) {
+      db_iter_->~DBIter();
+    } else {
+      assert(false);
+    }
+  }
 
   // Get the arena to be used to allocate memory for DBIter to be wrapped,
   // as well as child iterators in it.
@@ -90,7 +96,7 @@ class ArenaWrappedDBIter : public Iterator {
   }
 
  private:
-  DBIter* db_iter_;
+  DBIter* db_iter_ = nullptr;
   Arena arena_;
   uint64_t sv_number_;
   ColumnFamilyData* cfd_ = nullptr;