You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by fg...@apache.org on 2024/11/12 20:02:02 UTC
(nifi-minifi-cpp) 03/03: MINIFICPP-2487 - Destroy PyException while holding GIL
This is an automated email from the ASF dual-hosted git repository.
fgerlits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git
commit 02d4e630e81d9d04a8ab0f5fe56682e33329e684
Author: Adam Debreceni <ad...@apache.org>
AuthorDate: Tue Nov 5 13:17:43 2024 +0100
MINIFICPP-2487 - Destroy PyException while holding GIL
PyException holds a reference to the python exception object. When it escapes
the scope of the GIL (into an outer catch block), its destruction crashes the
application, and the python library logs the reason as not holding the lock.
This can occur when e.g. the describe function is malformed (declared with the
incorrect number of positional arguments).
Signed-off-by: Ferenc Gerlits <fg...@gmail.com>
This closes #1891
---
extensions/python/PythonScriptEngine.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/extensions/python/PythonScriptEngine.h b/extensions/python/PythonScriptEngine.h
index 5823d6f1e..4a266ea57 100644
--- a/extensions/python/PythonScriptEngine.h
+++ b/extensions/python/PythonScriptEngine.h
@@ -81,7 +81,7 @@ class PythonScriptEngine {
if (auto item = bindings_[fn_name]) {
auto result = BorrowedCallable(*item)(std::forward<Args>(args)...);
if (!result) {
- throw PyException();
+ throw PythonScriptException(PyException().what());
}
return result;
} else {
@@ -136,7 +136,7 @@ class PythonScriptEngine {
auto result = callable_method(std::forward<Args>(args)...);
if (!result) {
- throw PyException();
+ throw PythonScriptException(PyException().what());
}
return result;
}