Skip to content

Commit 058992e

Browse files
authored
[lldb] Fix Python GIL-not-held issue in CreateStructuredDataFromScriptObject (#136309)
TestStructuredDataAPI.py fails with Python debug build ver. 3.12+ due to call to Py_XINCREF while GIL is not held.
1 parent 15e662b commit 058992e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1569,10 +1569,10 @@ StructuredData::ObjectSP
15691569
ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject(
15701570
ScriptObject obj) {
15711571
void *ptr = const_cast<void *>(obj.GetPointer());
1572+
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
15721573
PythonObject py_obj(PyRefType::Borrowed, static_cast<PyObject *>(ptr));
15731574
if (!py_obj.IsValid() || py_obj.IsNone())
15741575
return {};
1575-
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
15761576
return py_obj.CreateStructuredObject();
15771577
}
15781578

0 commit comments

Comments
 (0)