From 579eced9054f3134e127d4ec24f2376201441729 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 16 Feb 2021 16:50:18 -0500 Subject: [PATCH] mon/ConfigMap: fix stray option leak The const Option* needs to remain alive only until the next clear(). Keep the reference in ConfigMap and clean it up then. Signed-off-by: Sage Weil (cherry picked from commit 9397a46aec88e287d56a6286ed4319f65d9c1f31) Fixes: https://tracker.ceph.com/issues/48381 Conflicts: src/mon/ConfigMap.h: trivial resolution --- src/mon/ConfigMap.h | 2 ++ src/mon/ConfigMonitor.cc | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mon/ConfigMap.h b/src/mon/ConfigMap.h index 17b52af1d1d1d..9c0a2a9f26764 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -99,6 +99,7 @@ struct ConfigMap { Section global; std::map by_type; std::map by_id; + std::list> stray_options; Section *find_section(const std::string& name) { if (name == "global") { @@ -118,6 +119,7 @@ struct ConfigMap { global.clear(); by_type.clear(); by_id.clear(); + stray_options.clear(); } void dump(Formatter *f) const; std::map> generate_entity_map( diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index 31b459611a5b4..5ef80e7003992 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -756,8 +756,10 @@ void ConfigMonitor::load_config() } if (!opt) { dout(10) << __func__ << " unrecognized option '" << name << "'" << dendl; - opt = new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN); - // FIXME: this will be leaked! + config_map.stray_options.push_back( + std::unique_ptr