[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
Mon Aug 15 11:03:53 PDT 2022


clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So any functions that are "StructureData::<class> *" raw pointers in this source code should switch over to returning on of the StruturedData definitions from StructuredData.h:

  class StructuredData {
    typedef std::shared_ptr<Object> ObjectSP;
    typedef std::shared_ptr<Array> ArraySP;
    typedef std::shared_ptr<Integer> IntegerSP;
    typedef std::shared_ptr<Float> FloatSP;
    typedef std::shared_ptr<Boolean> BooleanSP;
    typedef std::shared_ptr<String> StringSP;
    typedef std::shared_ptr<Dictionary> DictionarySP;
    typedef std::shared_ptr<Generic> GenericSP;



================
Comment at: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp:227
 
 static StructuredData::Array *ConvertToStructuredArray(
     ValueObjectSP return_value_sp, const std::string &items_name,
----------------
JDevlieghere wrote:
> fixathon wrote:
> > Function creating heap-based allocation
> Could this return a unique_ptr instead?
This should return StructureData::ArraySP. Look at the other usages of this function where they will eventually put the result into a dictionary


================
Comment at: lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp:351
 
   StructuredData::Array *stacks = ConvertToStructuredArray(
       main_value, ".stacks", ".stack_count",
----------------
If we make ConvertToStructuredArray return a ArraySP, then this code would change


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