Skip to content

Commit c2be872

Browse files
committed
[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 <[email protected]>
1 parent 8824c52 commit c2be872

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lldb/bindings/python/python-typemaps.swig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
if (!$result) {
6262
$result = Py_None;
6363
Py_INCREF(Py_None);
64+
} else {
65+
Py_INCREF($result);
6466
}
6567
}
6668

lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ def cleanup():
8585
self.assertEqual(process.GetProcessID(), 666)
8686
self.assertEqual(process.GetNumThreads(), 0)
8787

88+
impl = process.GetScriptedImplementation()
89+
self.assertTrue(impl)
90+
impl = process.GetScriptedImplementation()
91+
self.assertTrue(impl)
92+
impl = process.GetScriptedImplementation()
93+
self.assertTrue(impl)
94+
impl = process.GetScriptedImplementation()
95+
self.assertTrue(impl)
96+
8897
addr = 0x500000000
8998
buff = process.ReadMemory(addr, 4, error)
9099
self.assertEqual(buff, None)

0 commit comments

Comments
 (0)