[Lldb-commits] [PATCH] D131900: [LLDB][NFC] Fix memory leak in IntstumentationRuntimeTSan.cpp

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 16 11:33:14 PDT 2022


clayborg added a comment.

Looks great, maybe fix the pass by value in the callback and this is good?



================
Comment at: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp:230
+    std::function<void(ValueObjectSP o,
+                       StructuredData::DictionarySP dict)> const &callback) {
+  auto array_sp = std::make_shared<StructuredData::Array>();
----------------
Pass by reference to avoid an increment and decrement in the shared pointer due to a copy


================
Comment at: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp:347-348
                            ->GetValueAsUnsigned(0));
-  dict->AddItem("sleep_trace", StructuredData::ObjectSP(CreateStackTrace(
-                                   main_value, ".sleep_trace")));
+  dict->AddItem("sleep_trace", CreateStackTrace(
+                                   main_value, ".sleep_trace"));
 
----------------
combine this line


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131900/new/

https://reviews.llvm.org/D131900



More information about the lldb-commits mailing list