]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix UB while registering perf counters 40680/head
authorArthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Wed, 24 Mar 2021 09:05:07 +0000 (10:05 +0100)
committersinguliere <singuliere@autistici.org>
Fri, 9 Apr 2021 05:35:22 +0000 (07:35 +0200)
register_perf_counters was called before m_image_spec initialization
resulting in UB in the perf counters' name.

This moves the register_perf_counters() call to the init function
after the m_image_spec initialization.

Fixes: https://tracker.ceph.com/issues/49959
Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
(cherry picked from commit 5e3b9d29b3a81923fed51248aa21749dbecfcd73)

src/tools/rbd_mirror/image_replayer/journal/Replayer.cc

index ea0f9093c3b7c98fa69e7a83b2d82c1c2564b0d5..a2d47f5505155156ef5a6b5776b1394cf0682adc 100644 (file)
@@ -148,11 +148,6 @@ Replayer<I>::Replayer(
     m_lock(ceph::make_mutex(librbd::util::unique_lock_name(
       "rbd::mirror::image_replayer::journal::Replayer", this))) {
   dout(10) << dendl;
-
-  {
-    std::unique_lock locker{m_lock};
-    register_perf_counters();
-  }
 }
 
 template <typename I>
@@ -186,6 +181,11 @@ void Replayer<I>::init(Context* on_finish) {
                                             local_image_ctx->name);
   }
 
+  {
+    std::unique_lock locker{m_lock};
+    register_perf_counters();
+  }
+
   ceph_assert(m_on_init_shutdown == nullptr);
   m_on_init_shutdown = on_finish;