From 6c018822ba40cc0a4427bd3f9ab8c96829c207df Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 6 Apr 2017 18:04:32 +0200 Subject: Fix crash on exit with debug Python 3 Crash happens because of an use-after-free error. This is a bandaid fix transforming the crash into a memory leak. Proper fix will require more investigation and time. Task-number: PYSIDE-488 Change-Id: I56358573ca60d6f18fd85fbd7eb3eb0da8fbf163 Reviewed-by: Christian Tismer --- libshiboken/sbkenum.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp index 0902077ed..009d9ab2f 100644 --- a/libshiboken/sbkenum.cpp +++ b/libshiboken/sbkenum.cpp @@ -487,7 +487,12 @@ bool createGlobalEnumItem(PyTypeObject* enumType, PyObject* module, const char* if (enumItem) { if (PyModule_AddObject(module, itemName, enumItem) < 0) return false; - Py_DECREF(enumItem); + // @TODO This Py_DECREF causes crashes on exit with a debug Python interpreter, essentially + // causing a use-after-free in the GC. This is now commented out to cause a memory leak + // instead of a crash. Proper memory management of Enum types and items should be + // implemented. See PYSIDE-488. This will require proper allocation and deallocation of + // the underlying Enum PyHeapType, which is currently just deallocated at application exit. + // Py_DECREF(enumItem); return true; } return false; -- cgit v1.2.3