]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ceph_context: leak some memory fail to show in valgrind 47933/head
authorNitzanMordhai <nmordech@redhat.com>
Thu, 25 Aug 2022 11:18:56 +0000 (11:18 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 2 Sep 2022 17:08:03 +0000 (17:08 +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>
(cherry picked from commit fc21669d262117312b290c004390a70d92b9acea)

src/common/ceph_context.cc

index df23ae7a60f1842ef03bbcba828bfeb3c0b59c61..e52c626e57c6f76ba433109a6e6774822a956a41 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") {