Closed ygorelik closed 1 year ago
This issue persist with Python 3.10.4.
I doubt this is a real fix, but I've worked around this problem with the following:
index 135fe85b..a4f42608 100644
--- a/sdk/python/core/python.cpp
+++ b/sdk/python/core/python.cpp
@@ -92,10 +92,15 @@ void setup_logging()
add_null_handler(logger);
log_debug = logger.attr("debug");
+ log_debug.inc_ref();
log_info = logger.attr("info");
+ log_info.inc_ref();
log_warning = logger.attr("warning");
+ log_warning.inc_ref();
log_error = logger.attr("error");
+ log_error.inc_ref();
log_critical = logger.attr("critical");
+ log_critical.inc_ref();
ydk::set_logging_callback("debug", debug);
ydk::set_logging_callback("info", info);
diff --git a/sdk/python/gnmi/python_gnmi.cpp b/sdk/python/gnmi/python_gnmi.cpp
index 7569e374..a424fd70 100644
--- a/sdk/python/gnmi/python_gnmi.cpp
+++ b/sdk/python/gnmi/python_gnmi.cpp
@@ -82,10 +82,15 @@ static void setup_gnmi_logging()
add_null_handler(logger);
log_debug = logger.attr("debug");
+ log_debug.inc_ref();
log_info = logger.attr("info");
+ log_info.inc_ref();
log_warning = logger.attr("warning");
+ log_warning.inc_ref();
log_error = logger.attr("error");
+ log_error.inc_ref();
log_critical = logger.attr("critical");
+ log_critical.inc_ref();
This is great, ekinzie! Thank you for the contribution. I will include your fix to release 0.8.6.4.
It is quite possible that it also fixes the issue #1074, which is related to the logging.
Applied this fix to maintenance release 0.8.6.5 (under development).
Current Behavior
When upgraded Python to version 3.9.5, it is noticed that all YDK Python applications exit with Segmentation Fault.
Investigation showed that this is well known Python 3.9 issue documented in multiple resources; here is one of them.
Root cause: At application exit the pybind objects got deleted AFTER corresponding memory was released.
Steps to Reproduce
After Python upgrade/installation to version 3.9.x and YDK installation run sanity test and notice segmentation fault:
Logs
The following application crash information was obtained on MACOS Mojave with Python 3.5.9:
System Information
YDK installation on MACOS Mohave with Python 3.9.5.
Workaround
Downgrade Python to version 3.7.x, which is proven to be stable for YDK applications.