[Lldb-commits] [PATCH] D117071: [lldb/Plugins] Add support of multiple ScriptedThreads in a ScriptedProcess

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 12 07:57:36 PST 2022


mib added a subscriber: labath.
mib added inline comments.


================
Comment at: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp:332
+    lldb::ThreadSP thread_sp =
+        std::make_shared<ScriptedThread>(*this, error, *val->GetAsGeneric());
+
----------------
@labath This is why I switched to a raw pointer in D117065. Basically, I fetch a python dictionary for the `thread_info_sp`. It gets converted to a `StructuredData::Dictionary` and every element gets re-allocated in `pythonObject::CreateStructuredDictionary`. Then I iterate over each of element of the StructuredData::Dictionary and passes the StructuredData::Object to the ScriptedThread constructor.

The ScriptedThread needs a valid reference to the python object instance to perform calls on it. However, when the structured dictionary goes out of scope (at the end of the function), all the objects it holds get destroyed so when the ScriptedThread tries to make a call on the python object is causes a heap-use-after-free.


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

https://reviews.llvm.org/D117071



More information about the lldb-commits mailing list