From: Aliaksei Makarau Date: Tue, 31 May 2022 07:24:19 +0000 (+0200) Subject: mds/fsmap: proper update of filesystems X-Git-Tag: v18.0.0~752^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=80d5dcb4c6a4b2e5d6079dfb62d86b37326b6cc4;p=ceph.git mds/fsmap: proper update of filesystems Segfault was triggered by the fs/multifs test. The problem is in potential undefined behaviour afer erasing element and iterator invalidation in FSMap::stop() and FSMap::erase(). Fixed by decoupling element removal from the loop. Fixes: https://tracker.ceph.com/issues/55620 Signed-off-by: Aliaksei Makarau --- diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index 217a1e3307c5..b9ae05ac0f62 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -1090,10 +1090,13 @@ std::vector FSMap::stop(mds_gid_t who) if (other_info.rank == info.rank && other_info.state == MDSMap::STATE_STANDBY_REPLAY) { standbys.push_back(other_gid); - erase(other_gid, 0); } } + for (const auto &other_gid : standbys) { + erase(other_gid, 0); + } + fs->mds_map.mds_info.erase(who); mds_roles.erase(who);