diff options
author | Christian Tismer <tismer@stackless.com> | 2020-04-08 14:46:03 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-04-08 17:07:43 +0200 |
commit | 52299827c64cccc1456f9050fdf3dd8596df3e6f (patch) | |
tree | 314bc40d5eaf3a792fa2a2bb10be1e2e60631e68 | |
parent | 4fc3a3ac713cdde1453619ecf1116604c36d82b5 (diff) |
shiboken: Fix race condition with unprotected Py_INCREFs
The signalmanager module contains a PyObjectWrapper object
into which PySide::SignalManager::qt_metacall calls via many
hard-to-track indirections.
Finding this problem was quite tricky. It was done by modifying
the Py_INCREF and Py_DECREF macros of a debug Python
interpreter and using the new PyGILState_Check function to
provoke a crash if the GIL was not held.
See the online documentation for details.
Change-Id: Ida8246c97dcf6443ff057d206a42d22e462f1913
Fixes: PYSIDE-813
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | sources/pyside2/libpyside/signalmanager.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp index 0fe0d0092..8e8cc9f02 100644 --- a/sources/pyside2/libpyside/signalmanager.cpp +++ b/sources/pyside2/libpyside/signalmanager.cpp @@ -114,18 +114,24 @@ namespace PySide { PyObjectWrapper::PyObjectWrapper() :m_me(Py_None) { + // PYSIDE-813: When PYSIDE-164 was solved by adding some thread allowance, + // this code was no longer protected. It was hard to find this connection. + // See the website https://bugreports.qt.io/browse/PYSIDE-813 for details. + Shiboken::GilState gil; Py_XINCREF(m_me); } PyObjectWrapper::PyObjectWrapper(PyObject *me) : m_me(me) { + Shiboken::GilState gil; Py_XINCREF(m_me); } PyObjectWrapper::PyObjectWrapper(const PyObjectWrapper &other) : m_me(other.m_me) { + Shiboken::GilState gil; Py_XINCREF(m_me); } @@ -142,6 +148,7 @@ PyObjectWrapper::~PyObjectWrapper() void PyObjectWrapper::reset(PyObject *o) { + Shiboken::GilState gil; Py_XINCREF(o); Py_XDECREF(m_me); m_me = o; |