From: Casey Bodley Date: Wed, 9 Apr 2025 19:26:51 +0000 (-0400) Subject: common: CephContext::_refresh_perf_values() checks for null _mempool_perf X-Git-Tag: testing/wip-pdonnell-testing-20250421.184056-debug~35^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=76b3f0118cad36aa522802b181b03cdc0cdd3942;p=ceph-ci.git common: CephContext::_refresh_perf_values() checks for null _mempool_perf test_perf_counters_cache.cc initializes the CephContext with flag CINIT_FLAG_NO_CCT_PERF_COUNTERS which leaves both _cct_perf and _mempool_perf as nullptrs the CephContextServiceThread calls _refresh_perf_values() regularly, which guards _cct_perf->set() calls with a nullptr check, but the _mempool_perf->set() calls were unguarded this led to occasional unittest_perf_counters_cache segfaults in make check Fixes: https://tracker.ceph.com/issues/64895 Signed-off-by: Casey Bodley --- diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 8e6cbcf39a1..c37045337cc 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -999,11 +999,13 @@ void CephContext::_refresh_perf_values() _cct_perf->set(l_cct_total_workers, _heartbeat_map->get_total_workers()); _cct_perf->set(l_cct_unhealthy_workers, _heartbeat_map->get_unhealthy_workers()); } - unsigned l = l_mempool_first + 1; - for (unsigned i = 0; i < mempool::num_pools; ++i) { - mempool::pool_t& p = mempool::get_pool(mempool::pool_index_t(i)); - _mempool_perf->set(l++, p.allocated_bytes()); - _mempool_perf->set(l++, p.allocated_items()); + if (_mempool_perf) { + unsigned l = l_mempool_first + 1; + for (unsigned i = 0; i < mempool::num_pools; ++i) { + mempool::pool_t& p = mempool::get_pool(mempool::pool_index_t(i)); + _mempool_perf->set(l++, p.allocated_bytes()); + _mempool_perf->set(l++, p.allocated_items()); + } } }