[pygobject] Ignore closure callbacks when Python is not initialized



commit 16f8f687eae0caa1e4059fd62bd1f9d4c7f655f7
Author: Simon Feltman <sfeltman src gnome org>
Date:   Wed Aug 27 23:55:06 2014 -0700

    Ignore closure callbacks when Python is not initialized
    
    Add an immediate return in ffi closures if Python is not initialized.
    This fixes rare events when which lead to a segfault when a process
    is exiting.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722562

 gi/pygi-closure.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index 599503f..2a5a120 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -552,6 +552,13 @@ _pygi_closure_handle (ffi_cif *cif,
     gboolean success;
     PyGIInvokeState state = { 0, };
 
+    /* Ignore closures when Python is not initialized. This can happen in cases
+     * where calling Python implemented vfuncs can happen at shutdown time.
+     * See: https://bugzilla.gnome.org/show_bug.cgi?id=722562 */
+    if (!Py_IsInitialized()) {
+        return;
+    }
+
     /* Lock the GIL as we are coming into this code without the lock and we
       may be executing python code */
     py_state = PyGILState_Ensure ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]