[Lldb-commits] [PATCH] D117065: [lldb/Plugins] Fix ScriptedInterface object ptr use-after-free
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 12 03:32:41 PST 2022
labath requested changes to this revision.
labath added inline comments.
This revision now requires changes to proceed.
================
Comment at: lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp:54
+ m_object_instance = static_cast<StructuredData::Generic *>(
+ new StructuredPythonObject(ret_val));
----------------
This doesn't sound right. This object (`StructuredPythonObject` instance) is definitely not created by python and will now be leaked. If I correctly understand the problem, the issue is that the this object gets a non-owning reference (the `ret_val` argument) to the underlying python object, and then frees it as if it was owning it. If that's the case, then the solution is to INCREF it in the constructor (or switch to using a PythonObject wrapper, which will then handle the lifetime management.
You may also be interested in D114722 (which I hope to update soon). It's not _directly_ related to this, but it touches the same parts of the code.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117065/new/
https://reviews.llvm.org/D117065
More information about the lldb-commits
mailing list