aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-04-06 18:04:32 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-06-27 15:39:15 +0000
commit4f8543babe99fb36b84bec81f62d592aae948417 (patch)
tree343723dd5830aeb6146de7098bc79a312d1453ae
parentcdf8c68066e79e25c17eb725e4a471b0b83df544 (diff)
[Reland] 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. The commit was missing in 5.9 branch after repo merge. Task-number: PYSIDE-488 Change-Id: I56358573ca60d6f18fd85fbd7eb3eb0da8fbf163 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken2/libshiboken/sbkenum.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp
index 0902077ed..009d9ab2f 100644
--- a/sources/shiboken2/libshiboken/sbkenum.cpp
+++ b/sources/shiboken2/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;