[Lldb-commits] [lldb] ebdbc26 - [lldb/swig] Fix ref counting issue in SBProcess::GetScriptedImplementation
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 3 19:33:27 PST 2023
Author: Med Ismail Bennani
Date: 2023-03-03T19:33:02-08:00
New Revision: ebdbc26a3e79e64e9b2786a8b413618a5b5c115d
URL: https://github.com/llvm/llvm-project/commit/ebdbc26a3e79e64e9b2786a8b413618a5b5c115d
DIFF: https://github.com/llvm/llvm-project/commit/ebdbc26a3e79e64e9b2786a8b413618a5b5c115d.diff
LOG: [lldb/swig] Fix ref counting issue in SBProcess::GetScriptedImplementation
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.
Differential Revision: https://reviews.llvm.org/D145260
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/bindings/python/python-typemaps.swig
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
Removed:
################################################################################
diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig
index 2057aa6b42b6..1b1f2e1fe266 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -61,6 +61,8 @@
if (!$result) {
$result = Py_None;
Py_INCREF(Py_None);
+ } else {
+ Py_INCREF($result);
}
}
diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
index 5a198cc95704..b5a14a9cd63d 100644
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
@@ -80,6 +80,15 @@ def cleanup():
self.assertEqual(process.GetProcessID(), 666)
self.assertEqual(process.GetNumThreads(), 0)
+ impl = process.GetScriptedImplementation()
+ self.assertTrue(impl)
+ impl = process.GetScriptedImplementation()
+ self.assertTrue(impl)
+ impl = process.GetScriptedImplementation()
+ self.assertTrue(impl)
+ impl = process.GetScriptedImplementation()
+ self.assertTrue(impl)
+
addr = 0x500000000
buff = process.ReadMemory(addr, 4, error)
self.assertEqual(buff, None)
More information about the lldb-commits
mailing list