[Lldb-commits] [PATCH] D145260: [lldb/swig] Fix ref counting issue in SBProcess::GetScriptedImplementation

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 3 11:57:16 PST 2023


mib created this revision.
mib added reviewers: bulbazord, JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

When using SBProcess::GetScriptedImplementation in python, if the
process has a valid implementation, we returned a reference of the
object without incrementing the reference counting. That causes the
interpreter to crash after accessing the reference several times.

This patch address this by incrementing the reference count when passing
the valid object reference.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145260

Files:
  lldb/bindings/python/python-typemaps.swig


Index: lldb/bindings/python/python-typemaps.swig
===================================================================
--- lldb/bindings/python/python-typemaps.swig
+++ lldb/bindings/python/python-typemaps.swig
@@ -61,6 +61,8 @@
   if (!$result) {
     $result = Py_None;
     Py_INCREF(Py_None);
+  } else {
+    Py_INCREF($result);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145260.502210.patch
Type: text/x-patch
Size: 342 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230303/502b79e4/attachment-0001.bin>


More information about the lldb-commits mailing list