[PySide] Issues with threads after updating to PySide/shiboken 5.14.2
Christian Tismer
tismer at stackless.com
Mon Apr 20 12:04:30 CEST 2020
Hi Christoph,
On 19.04.20 13:27, icfwm at gmx.net wrote:
...
> Updating to PySide/shiboken 5.14.2 forced me to set allow-threads to
> true or auto for the c++ library wrapper since the default setting
> introduced dead-locking, probably due to the way the inter-thread
> communication has been implemented. Afterwards, everything seemed to
> work, but I am observing infrequent, hard-to-reproduce crashes,
> sometimes showing stack traces full of python3 / PySide / shiboken2
> functions with neither of my own code nor shiboken wrappers of the
> c++ library in it. Sometimes stack traces seem to indicate that
> QSharedPointers are deleted too early while there are still active
> references.
>
> Configuring the application to use only one thread heals the crashes.
> Going back to 5.14.1 using exactly same python, c++, and
> typesystem.xml doesn't show crashes as well, even when using multiple
> threads.
...
Are you sure that you really have the freshest version of 5.14.2? There
have been updates, so I want to make sure that we are talking of the
right version.
We have admittedly made a few heavy changes with some impact on threads.
For one, we removed the auto-allowing threads because PYSIDE-803 became
*unreactive*. The many allow-threads were bad, because each one costs
one 5ms cycle on the GIL carousel when there are computing threads.
So this maybe was a bit too much. allow-threads should come in two
flavours:
"We must allow threads or we get a hang"
and
"We should allow threads when this computes too long"
Unfortunately we don't have such a distinction.
The first one is essential, while the second one got less urgent or even
counter-productive, because computers became much faster, but the 5ms
carousel was never adapted, accoudingly. I think Python should change
the default.
So that was for PYSIDE-803. The consequences still need adjustment.
Observing random crashes was a thing that was tackled in PYSIDE-813/164.
Because PYSIDE-164 added allow-threads to avoid a blocking problem,
there popped PYSIDE-813 up: When using many threads that sent messages
to each other, then we got random crashes. After a long search, this
turned out to be a race condition where somebody thought that he could
Py_INCREF a variable without holding the GIL. He can not!
So it is possibly already solved and you need to update, or maybe there
is another such case hiding somewhere.
To be sure, you could run this program:
https://bugreports.qt.io/secure/attachment/92459/pyside813.py
If this does not crash, then we know that you have a new bug :-)
Ciao -- Chris
--
Christian Tismer-Sperling :^) tismer at stackless.com
Software Consulting : http://www.stackless.com/
Strandstraße 37 : https://github.com/PySide
24217 Schönberg : GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776 fax +49 (30) 700143-0023
More information about the PySide
mailing list