Skip to content

Commit c0f5359

Browse files
committed
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 <[email protected]>
1 parent 466112e commit c0f5359

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/rbd_mirror/test_mock_PoolReplayer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,15 @@ class Namespace<MockTestImageCtx> {
5656
}
5757

5858
Namespace() {
59+
ceph_assert(s_instance == nullptr);
5960
s_instance = this;
6061
}
6162

63+
~Namespace() {
64+
ceph_assert(s_instance == this);
65+
s_instance = nullptr;
66+
}
67+
6268
void add(const std::string &name) {
6369
std::lock_guard locker{m_lock};
6470

0 commit comments

Comments
 (0)