]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rbd_mirror: clear Namespace::s_instance at the end of a test 61960/head
authorIlya Dryomov <idryomov@gmail.com>
Tue, 18 Feb 2025 16:51:47 +0000 (17:51 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Sat, 22 Feb 2025 15:19:08 +0000 (16:19 +0100)
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 <idryomov@gmail.com>
(cherry picked from commit c0f5359b7b47bb424d700f69a2af43ab81fa87c2)

src/test/rbd_mirror/test_mock_PoolReplayer.cc

index 69fe799314810327ae010cc3ad38bd9fede606f2..c56ed815070c5011aa5228ed73bda24ecce39465 100644 (file)
@@ -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};