From da55f0ab140e7a82cf529e01353778d3c4352b7e Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Tue, 5 Sep 2023 18:35:05 +0300 Subject: [PATCH] Protection from double deallocation of queued buffers, thanks to Vlad. Usually this should not happen, but possible after error thrown during commit (while journal/replica flushing). --- src/jrd/replication/Manager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/jrd/replication/Manager.cpp b/src/jrd/replication/Manager.cpp index 5070499ac2..b2f020727c 100644 --- a/src/jrd/replication/Manager.cpp +++ b/src/jrd/replication/Manager.cpp @@ -187,11 +187,9 @@ Manager::Manager(const string& dbId, Manager::~Manager() { fb_assert(m_shutdown); + fb_assert(m_queue.isEmpty()); fb_assert(m_replicas.isEmpty()); - for (auto buffer : m_queue) - delete buffer; - for (auto buffer : m_buffers) delete buffer; } @@ -208,6 +206,13 @@ void Manager::shutdown() MutexLockGuard guard(m_queueMutex, FB_FUNCTION); + // Clear the processing queue + + for (auto buffer : m_queue) + releaseBuffer(buffer); + + m_queue.clear(); + // Detach from synchronous replicas for (auto iter : m_replicas)