]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_context: leak some memory fail to show in valgrind 47802/head
authorNitzanMordhai <nmordech@redhat.com>
Thu, 25 Aug 2022 11:18:56 +0000 (11:18 +0000)
committerNitzanMordhai <nmordech@redhat.com>
Thu, 25 Aug 2022 15:39:57 +0000 (15:39 +0000)
GCC 20 memory optimization broke the memory leak for testing.

Fixes:https://tracker.ceph.com/issues/57165
Signed-off-by: Nitzan Mordechai <nmordec@redhat.com>
src/common/ceph_context.cc

index 7c72e16fd3cce4797f3ae807336a8af832cfd1e7..029f9b9496e3bb3d780f89d1258500d326fbc1f8 100644 (file)
@@ -502,6 +502,14 @@ int CephContext::do_command(std::string_view command, const cmdmap_t& cmdmap,
   }
 }
 
+#pragma GCC push_options
+#pragma GCC optimize ("O0")
+static void leak_some_memory() {
+  volatile char *foo = new char[1234];
+  (void)foo;
+}
+#pragma GCC pop_options
+
 int CephContext::_do_command(
   std::string_view command, const cmdmap_t& cmdmap,
   Formatter *f,
@@ -520,8 +528,7 @@ int CephContext::_do_command(
     }
   }
   if (command == "leak_some_memory") {
-    char *foo = new char[1234];
-    (void)foo;
+    leak_some_memory();
   }
   else if (command == "perfcounters_dump" || command == "1" ||
       command == "perf dump") {