[Commits] 3ce77681b: Fix one-off memory leak for ASAN

Sergei Petrunia psergey at askmonty.org
Sun Jan 27 20:40:26 EET 2019


revision-id: 3ce77681b7cc369e2f5c2a1f83216eb62776065d (v5.8-1030-g3ce77681b)
parent(s): fbca006149dc8e4b2087fb0f0866bbb7ff202950
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2019-01-27 21:40:26 +0300
message:

Fix one-off memory leak for ASAN

One must call destroy() method for toku::comparator

---
 utilities/transactions/transaction_lock_mgr.cc | 6 +++---
 utilities/transactions/transaction_lock_mgr.h  | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc
index d8a3fa28f..4c1417630 100644
--- a/utilities/transactions/transaction_lock_mgr.cc
+++ b/utilities/transactions/transaction_lock_mgr.cc
@@ -1057,10 +1057,9 @@ RangeLockMgr::set_endpoint_cmp_functions(convert_key_to_endpoint_func cvt_func,
   // The rest is like a constructor:
   assert(!lt);
 
-  toku::comparator cmp;
-  cmp.create(compare_dbt_endpoints, (void*)this, NULL);
+  cmp_.create(compare_dbt_endpoints, (void*)this, NULL);
   DICTIONARY_ID dict_id = { .dictid = 1 };
-  lt= ltm.get_lt(dict_id, cmp , /* on_create_extra*/nullptr);
+  lt= ltm.get_lt(dict_id, cmp_, /* on_create_extra*/nullptr);
 }
 
 RangeLockMgr::~RangeLockMgr() {
@@ -1068,6 +1067,7 @@ RangeLockMgr::~RangeLockMgr() {
     ltm.release_lt(lt);
   }
   ltm.destroy();
+  cmp_.destroy();
 }
 
 uint64_t RangeLockMgr::get_escalation_count() {
diff --git a/utilities/transactions/transaction_lock_mgr.h b/utilities/transactions/transaction_lock_mgr.h
index 302d6ecee..31503c1e4 100644
--- a/utilities/transactions/transaction_lock_mgr.h
+++ b/utilities/transactions/transaction_lock_mgr.h
@@ -239,6 +239,8 @@ class RangeLockMgr :
   toku::locktree_manager ltm;
   toku::locktree *lt; // only one tree for now
 
+  toku::comparator cmp_;
+
   // Convert rowkey to endpoint (TODO: shouldn't "rowkey=const" translate into
   // a pair of [start; end] endpoints in general? They translate into the same
   // value in our current encoding, but...)


More information about the commits mailing list