Skip to content

Commit eea9d06

Browse files
Besroyyawzhang
andauthored
Fix UT: address UAF in TestRaftLogStore lifecycle_test under ASan (eBay#860)
Co-authored-by: yawzhang <yawzhang@ebay.com>
1 parent 2e8cf2d commit eea9d06

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomestoreConan(ConanFile):
1111
name = "homestore"
12-
version = "7.4.2"
12+
version = "7.4.3"
1313

1414
homepage = "https://github.com/eBay/Homestore"
1515
description = "HomeStore Storage Engine"

src/lib/logstore/log_dev.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ void LogDev::stop() {
158158
// trigger a new flush to make sure all pending writes are flushed
159159
flush_under_guard();
160160

161+
{
162+
std::unique_lock lg = flush_guard();
163+
// wait again for any callbacks issued by new flush
164+
while (m_pending_callback.load() > 0) {
165+
THIS_LOGDEV_LOG(INFO, "Waiting for new pending callbacks to complete, pending callbacks {}",
166+
m_pending_callback.load());
167+
std::this_thread::sleep_for(std::chrono::milliseconds{1000});
168+
}
169+
}
170+
161171
// after we call stop, we need to do any pending device truncations
162172
truncate();
163173
m_id_logstore_map.clear();
@@ -583,10 +593,12 @@ void LogDev::on_flush_completion(LogGroup* lg) {
583593

584594
// since we support out-of-order lsn write, so no need to guarantee the order of logstore write completion
585595
for (auto const& [idx, req] : req_map) {
596+
m_pending_callback++;
586597
auto callback_lambda = [this, dev_offset, idx, req]() {
587598
auto ld_key = logdev_key{idx, dev_offset};
588599
auto comp_cb = req->log_store->get_comp_cb();
589600
(req->cb) ? req->cb(req, ld_key) : comp_cb(req, ld_key);
601+
m_pending_callback--;
590602
};
591603

592604
// if we do not have repl_service, we run the callback in a random worker for the case of log store UT, where

0 commit comments

Comments
 (0)