From: Jos Collin Date: Wed, 13 Mar 2024 01:32:40 +0000 (+0530) Subject: cephfs_mirror: check m_instance_watcher and m_mirror_watcher before using them X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4515d4e235bceb7565db83ae524ba67fdcc4ded3;p=ceph.git cephfs_mirror: check m_instance_watcher and m_mirror_watcher before using them Fixes the crash: ``` std::scoped_lock::scoped_lock (__m=..., this=, this=, __m=...) at /usr/include/c++/11/mutex:655 cephfs::mirror::MirrorWatcher::is_failed (this=0x0) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/MirrorWatcher.h:56 cephfs::mirror::FSMirror::is_failed (this=0x557478284340) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/FSMirror.h:52 cephfs::mirror::Mirror::update_fs_mirrors (this=0x5574773c3e60) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/Mirror.cc:515 ``` Fixes: https://tracker.ceph.com/issues/64751 Signed-off-by: Jos Collin (cherry picked from commit 5b8b9c2f7738e0341807c1e0971c3dec90ac5491) --- diff --git a/src/tools/cephfs_mirror/FSMirror.h b/src/tools/cephfs_mirror/FSMirror.h index a9c1fab1025d9..dd0b135d78b63 100644 --- a/src/tools/cephfs_mirror/FSMirror.h +++ b/src/tools/cephfs_mirror/FSMirror.h @@ -47,9 +47,14 @@ public: bool is_failed() { std::scoped_lock locker(m_lock); - return m_init_failed || - m_instance_watcher->is_failed() || - m_mirror_watcher->is_failed(); + bool failed = m_init_failed; + if (m_instance_watcher) { + failed |= m_instance_watcher->is_failed(); + } + if (m_mirror_watcher) { + failed |= m_mirror_watcher->is_failed(); + } + return failed; } utime_t get_failed_ts() {