Fix db_stress memory leak ASAN error

Summary:
In case `--expected_values_path` is unset, we allocate a buffer internally to hold the expected DB state. This PR makes sure it is freed.
Closes https://github.com/facebook/rocksdb/pull/3804

Differential Revision: D7874694

Pulled By: ajkr

fbshipit-source-id: a8f7655e009507c4e639ceebfc3525d69c856e3b
main
Andrew Kryczka 7 years ago committed by Facebook Github Bot
parent fc522bdb3e
commit 4c5a3232e4
  1. 6
      tools/db_stress.cc

@ -888,8 +888,9 @@ class SharedState {
} }
} }
if (values_ == nullptr) { if (values_ == nullptr) {
values_ = values_allocation_.reset(
static_cast<std::atomic<uint32_t>*>(malloc(expected_values_size)); new std::atomic<uint32_t>[FLAGS_column_families * max_key_]);
values_ = &values_allocation_[0];
values_init_needed = true; values_init_needed = true;
} }
assert(values_ != nullptr); assert(values_ != nullptr);
@ -1116,6 +1117,7 @@ class SharedState {
std::vector<std::unordered_set<size_t> > no_overwrite_ids_; std::vector<std::unordered_set<size_t> > no_overwrite_ids_;
std::atomic<uint32_t>* values_; std::atomic<uint32_t>* values_;
std::unique_ptr<std::atomic<uint32_t>[]> values_allocation_;
// Has to make it owned by a smart ptr as port::Mutex is not copyable // Has to make it owned by a smart ptr as port::Mutex is not copyable
// and storing it in the container may require copying depending on the impl. // and storing it in the container may require copying depending on the impl.
std::vector<std::vector<std::unique_ptr<port::Mutex> > > key_locks_; std::vector<std::vector<std::unique_ptr<port::Mutex> > > key_locks_;

Loading…
Cancel
Save