<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi, </p>
<p><br>
</p>
<p>We're still experiencing this deadlock in PyQt 5.9. It manifests itself as the application being frozen. We haven't been able to produce a test case which faithfully reproduces the problem since it looks like a timing issue. <span style="font-size: 12pt;">We
 got the stack traces below when we attached to the frozen </span><span style="font-size: 12pt;">process with GDB on Linux.</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;"><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">The stack trace indicates that
 the main thread got stuck in QObject.connect in PyQtMonitor::monitor which </span></span><span style="font-size: 12pt;">was apparently added in 5.9</span><span style="font-size: 12pt;">. At the same time, the worker thread is in a QObject destructor. Any ideas?</span></p>
<p></p>
<div><br>
</div>
<div><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">So far we know that it happens on Windows, Mac and Linux and </span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">on</span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;"> Python
 3.5.2.</span></div>
<div><br>
</div>
<div>[ MAINTHREAD ]</div>
<div><br>
</div>
<div>#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38</div>
<div>#1  0x00007fcaee602055 in QBasicMutex::lockInternal() () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#2  0x00007fcaee6020a6 in QMutex::lock() () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#3  0x00007fcaee80635a in ?? () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#4  0x00007fcaee809acb in QObject::connect(QObject const*, char const*, QObject const*, char const*, Qt::ConnectionType) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#5  0x00007fcaeee6b0fd in PyQtMonitor::monitor(QObject*) () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#6  0x00007fcaeb99ce55 in sipSimpleWrapper_init () from target:/snap/hiri/x1/sip.so</div>
<div>#7  0x00007fcaf185bfe6 in type_call.lto_priv.175 (type=<optimized out>, args=0x7fcaf27b0048, kwds=0x0) at ../Objects/typeobject.c:905</div>
<div>#8  0x00007fcaf195254e in PyObject_Call (func=0x2071a88, arg=<optimized out>, kw=<optimized out>) at ../Objects/abstract.c:2165</div>
<div>#9  0x00007fcaeb99e8c6 in sipWrapInstance () from target:/snap/hiri/x1/sip.so</div>
<div>#10 0x00007fcaeb99249b in sip_api_convert_from_type () from target:/snap/hiri/x1/sip.so</div>
<div>#11 0x00007fcaeb99b088 in buildObject () from target:/snap/hiri/x1/sip.so</div>
<div>#12 0x00007fcaeb99b809 in call_method () from target:/snap/hiri/x1/sip.so</div>
<div>#13 0x00007fcaeb99ba0c in sip_api_call_method () from target:/snap/hiri/x1/sip.so</div>
<div>#14 0x00007fcaeee25da6 in sipVH_QtCore_1(PyGILState_STATE, void (*)(_sipSimpleWrapper*, PyGILState_STATE), _sipSimpleWrapper*, _object*, QObject*, QEvent*) () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#15 0x00007fcaeee27830 in sipQObject::eventFilter(QObject*, QEvent*) () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#16 0x00007fcaee7d8b44 in QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#17 0x00007fcae66b24f8 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#18 0x00007fcae66b98e7 in QApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#19 0x00007fcae70fa2ae in sipQApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/PyQt5.QtWidgets.so</div>
<div>#20 0x00007fcaee7d8eb8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#21 0x00007fcaeadbea90 in QWindow::setIcon(QIcon const&) () from target:/snap/hiri/x1/libQt5Gui.so.5</div>
<div>#22 0x00007fcae66da9b2 in QWidgetPrivate::setWindowIcon_sys() () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#23 0x00007fcae66f08f5 in QWidget::event(QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#24 0x00007fcae68746e2 in QSplashScreen::event(QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#25 0x00007fcae707c993 in sipQSplashScreen::event(QEvent*) () from target:/snap/hiri/x1/PyQt5.QtWidgets.so</div>
<div>#26 0x00007fcae66b24bc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#27 0x00007fcae66b98e7 in QApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#28 0x00007fcae70fa2ae in sipQApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/PyQt5.QtWidgets.so</div>
<div>#29 0x00007fcaee7d8eb8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#30 0x00007fcae66b62d8 in QApplicationPrivate::notifyWindowIconChanged() () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#31 0x00007fcae6f8499b in meth_QApplication_setWindowIcon () from target:/snap/hiri/x1/PyQt5.QtWidgets.so</div>
<div>#32 0x00007fcaf1879039 in PyCFunction_Call (func=0x7fcad0055360, args=0x7fcac01c5780, kwds=<optimized out>) at ../Objects/methodobject.c:109</div>
<div>#33 0x00007fcaf19851b5 in call_function (oparg=<optimized out>, pp_stack=0x7ffe72df4b60) at ../Python/ceval.c:4705</div>
<div>#34 PyEval_EvalFrameEx (f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:3236</div>
<div>#35 0x00007fcaf1a15c6c in _PyEval_EvalCodeWithName.lto_priv.1742 (_co=0x7fcaef9e1810, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=0, kws=0x0, kwcount=0, defs=0x0, </div>
<div>    defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at ../Python/ceval.c:4018</div>
<div>#36 0x00007fcaf1a15d43 in PyEval_EvalCodeEx (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>, kws=<optimized out>, kwcount=0, </div>
<div>    defs=0x0, defcount=0, kwdefs=0x0, closure=0x0) at ../Python/ceval.c:4039</div>
<div>#37 0x00007fcaf197d9cb in PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at ../Python/ceval.c:777</div>
<div>#38 0x00000000004029e0 in ?? ()</div>
<div>#39 0x0000000000402db5 in ?? ()</div>
<div>#40 0x00007fcaf1e72830 in __libc_start_main (main=0x401930, argc=1, argv=0x7ffe72df8e68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe72df8e58)</div>
<div>    at ../csu/libc-start.c:291</div>
<div>#41 0x0000000000401969 in ?? ()</div>
<div><br>
</div>
<div>[ WORKER ]</div>
<div><br>
</div>
<div>Thread 5 (Thread 0x7fcac1bfd700 (LWP 21348)):</div>
<div>#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225</div>
<div>#1  0x00007fcaf197d47f in PyCOND_TIMEDWAIT (cond=0x7fcaf1e42360 <gil_cond>, mut=0x7fcaf1e423e0 <gil_mutex>, us=5000) at ../Python/condvar.h:103</div>
<div>#2  take_gil (tstate=tstate@entry=0x7fcab401cb40) at ../Python/ceval_gil.h:224</div>
<div>#3  0x00007fcaf197d969 in PyEval_RestoreThread (tstate=0x7fcab401cb40) at ../Python/ceval.c:450</div>
<div>#4  0x00007fcaf199d67b in PyGILState_Ensure () at ../Python/pystate.c:821</div>
<div>#5  0x00007fcaeb994c94 in sip_api_is_py_method () from target:/snap/hiri/x1/sip.so</div>
<div>#6  0x00007fcaeee21369 in sipQObject::disconnectNotify(QMetaMethod const&) () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#7  0x00007fcaee80af73 in QObject::~QObject() () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#8  0x00007fcaeede45b9 in sipQObject::~sipQObject() () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#9  0x00007fcaee8043f8 in QObject::event(QEvent*) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#10 0x00007fcaeee2874b in sipQObject::event(QEvent*) () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#11 0x00007fcae66b24bc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#12 0x00007fcae66b98e7 in QApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Widgets.so.5</div>
<div>#13 0x00007fcae70fa2ae in sipQApplication::notify(QObject*, QEvent*) () from target:/snap/hiri/x1/PyQt5.QtWidgets.so</div>
<div>#14 0x00007fcaee7d8eb8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div><span style="font-size: 12pt;">#15 0x00007fcaee7db54b in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from target:/snap/hiri/x1/libQt5Core.so.5</span><br>
</div>
<div>#16 0x00007fcaee82bad3 in ?? () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#17 0x00007fcaebe63197 in g_main_context_dispatch () from target:/snap/hiri/x1/lib/x86_64-linux-gnu/libglib-2.0.so.0</div>
<div>#18 0x00007fcaebe633f0 in ?? () from target:/snap/hiri/x1/lib/x86_64-linux-gnu/libglib-2.0.so.0</div>
<div>#19 0x00007fcaebe6349c in g_main_context_iteration () from target:/snap/hiri/x1/lib/x86_64-linux-gnu/libglib-2.0.so.0</div>
<div>#20 0x00007fcaee82b11f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#21 0x00007fcaee7d74aa in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#22 0x00007fcaee605dfc in QThread::exec() () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#23 0x00007fcaeee3bc00 in sipQThread::run() () from target:/snap/hiri/x1/PyQt5.QtCore.so</div>
<div>#24 0x00007fcaee60a84a in ?? () from target:/snap/hiri/x1/libQt5Core.so.5</div>
<div>#25 0x00007fcaf15b56ba in start_thread (arg=0x7fcac1bfd700) at pthread_create.c:333</div>
<div>#26 0x00007fcaf1f593dd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109</div>
<div><br>
</div>
Thanks
<p></p>
<p>Milorad</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Milorad Pop-Tosic<br>
<b>Sent:</b> Wednesday, August 30, 2017 2:29:04 PM<br>
<b>To:</b> pyqt@riverbankcomputing.com<br>
<b>Subject:</b> Deadlock in 5.9.1</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p><span style="font-size: 12pt;">We're seeing a deadlock after upgrading from PyQt5.8.2 to 5.9.1.</span><span style="font-size: 12pt;"> </span><span style="font-size: 12pt;">Since our application is complex, it's difficult to pinpoint to what's causing this</span><span style="font-size: 12pt;">.
 The problem is intermittent, but it can be reproduced by </span>repeatedly<span style="font-size: 12pt;"> clicking on an action.</span><span style="font-size: 12pt;"> </span><span style="font-size: 12pt;">I managed to get this stacktrace with VisualStudio:</span><br>
</p>
<p><br>
</p>
<p></p>
<div> <span style="white-space:pre"> </span>ntdll.dll!_NtWaitForSingleObject@12()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>KernelBase.dll!WaitForSingleObjectEx()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>python35.dll!take_gil(_ts * tstate=0x1f194160) Line 224<span style="white-space:pre">
</span>C</div>
<div> <span style="white-space:pre"> </span>python35.dll!PyEval_RestoreThread(_ts * tstate=0x1f194160) Line 452<span style="white-space:pre">
</span>C</div>
<div> <span style="white-space:pre"> </span>python35.dll!PyGILState_Ensure() Line 821<span style="white-space:pre">
</span>C</div>
<div> <span style="white-space:pre"> </span>sip.pyd!689b3355()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>[Frames below may be incorrect and/or missing, no symbols loaded for sip.pyd]<span style="white-space:pre">
</span></div>
<div> <span style="white-space:pre"> </span>QtCore.pyd!654b68a4()<span style="white-space:pre">
</span>Unknown</div>
<div>><span style="white-space:pre"> </span>Qt5Core.dll!QObject::~QObject() Line 986<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>QtCore.pyd!654b4744()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QObject::event(QEvent * e=0x1e632358) Line 1273<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>QtCore.pyd!654b73a7()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>Qt5Widgets.dll!QApplicationPrivate::notify_helper(QObject * receiver=0x1e632358, QEvent * e) Line 3717<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Widgets.dll!QApplication::notify(QObject * receiver=0x1e632438, QEvent * e=0x19a6a948) Line 3680<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>QtWidgets.pyd!648bd38b()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1018<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver=0x00000000, int event_type, QThreadData * data=0x1e632438) Line 1678<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QEventDispatcherWin32::sendPostedEvents() Line 1062<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!qt_internal_proc(HWND__ * hwnd=0x00460908, unsigned int message=0x00000401, unsigned int wp=0x00000000, long lp=0x00000000) Line 236<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>user32.dll!__InternalCallWinProc@20()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>user32.dll!_UserCallWinProcCheckWow@36()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>user32.dll!_DispatchMessageWorker@8()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>user32.dll!_DispatchMessageW@4()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 634<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 211<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>Qt5Core.dll!QThread::exec() Line 515<span style="white-space:pre">
</span>C++</div>
<div> <span style="white-space:pre"> </span>QtCore.pyd!6543a023()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>kernel32.dll!@BaseThreadInitThunk@12()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>ntdll.dll!__RtlUserThreadStart()<span style="white-space:pre">
</span>Unknown</div>
<div> <span style="white-space:pre"> </span>ntdll.dll!__RtlUserThreadStart@8()<span style="white-space:pre">
</span>Unknown</div>
<div><br>
</div>
<div>As far as I understand this stacktrace, something is trying to get GIL at a QObject destruction, so I'm guessing that something that was supposed to release the GIL didn't. </div>
<div><br>
</div>
<div>We're going to keep trying to isolate the problem into a standalone test case, but <span style="font-size: 12pt;">any pointers would be much appreciated.</span></div>
<div><br>
</div>
<p></p>
<p>Thanks</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<p>Milorad</p>
<p></p>
</div>
</div>
</div>
</div>
</body>
</html>