From: Ilya Dryomov Date: Tue, 18 Feb 2025 16:51:47 +0000 (+0100) Subject: test/rbd_mirror: clear Namespace::s_instance at the end of a test X-Git-Tag: v19.2.3~351^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a54c69152af0a499b5164833e9914c74c02a4377;p=ceph.git test/rbd_mirror: clear Namespace::s_instance at the end of a test TestMockPoolReplayer.Namespaces and NamespacesError tests leave behind a dangling pointer to a stack-allocated MockNamespace which leads to an easily reproducible use-after-free and segfault when tests are shuffled. Fixes: https://tracker.ceph.com/issues/70041 Signed-off-by: Ilya Dryomov (cherry picked from commit c0f5359b7b47bb424d700f69a2af43ab81fa87c2) --- diff --git a/src/test/rbd_mirror/test_mock_PoolReplayer.cc b/src/test/rbd_mirror/test_mock_PoolReplayer.cc index 69fe79931481..c56ed815070c 100644 --- a/src/test/rbd_mirror/test_mock_PoolReplayer.cc +++ b/src/test/rbd_mirror/test_mock_PoolReplayer.cc @@ -56,9 +56,15 @@ public: } Namespace() { + ceph_assert(s_instance == nullptr); s_instance = this; } + ~Namespace() { + ceph_assert(s_instance == this); + s_instance = nullptr; + } + void add(const std::string &name) { std::lock_guard locker{m_lock};