[Lldb-commits] [lldb] [lldb] Set return status to Failed when Python command raises uncaught exception (PR #113996)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 31 07:12:01 PDT 2024
================
@@ -642,6 +649,16 @@ bool lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
+ if (PyErr_Occurred()) {
+ py_err_cleaner.~PyErr_Cleaner();
----------------
labath wrote:
I'm pretty sure this is undefined behavior (you calling the destructor does not stop the compiler from calling it again).
I think that a proper fix for this would be to change `PythonCallable::operator()` to return `Expected<PythonObject>` (and convert the python exception to llvm::error, etc). A lot of the PythonDataObject methods were converted to do that (see comment at the top of the header), but it looks like this is not one of them.
https://github.com/llvm/llvm-project/pull/113996
More information about the lldb-commits
mailing list