You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash during long running proccess in asyncio.create_subprocess_shell on Windows #62
Long running processes will eventually crash the entire PyQt GUI. Sometimes it just crashes to desktop without any output in the Python shell, and sometimes this error message appears:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\qasync\_windows.py", line 163, in run
events = self.__proactor.select(0.01)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\qasync\_windows.py", line 69, in select
self._poll(timeout)
File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\qasync\_windows.py", line 99, in _poll
with QtCore.QMutexLocker(self._lock):
RuntimeError: wrapped C/C++ object of type QMutex has been delet
The ffmpeg process continues as an orphaned process and finishes the job. Can anybody shed some light on what might be happening? I have tested the same code on Ubuntu and MacOS and have not encountered any issues.
I'm on PyQt 6.2.2 and Python 3.9.9.
Edit: I now understand that the error is happening because the QMutex object that is created on line 64 in windows.py is deleted before the loop at line 100 in the _poll function finishes. Just for fun I tried to remove the QMutexLocker by removing line 99: with QtCore.QMutexLocker(self._lock):
...and this actually prevents my app from crashing, but I assume this is not a solution and the lock was there for a reason.
I have the same issue with a long running Future. I solved it by using threading.Lock() instead of QMutex. Not sure if this could have a negative impact.
Edit: I had a freeze using threading.Lock(), i switched to multiprocessing.Lock(), it works well.
It is a common problem with Qt bindings for python, where a c++ object underneath gets deleted, and python then tries to use a reference to it. This needs a bit more digging and ideally a reproducible example. Perhaps a long sleep call, rather than an ffmpeg encode.
I'm also seeing this using (Py)Qt6 and Python 3.11 in https://github.com/dnadlinger/artiq/tree/qt6. No leads as to a reproducible example, unfortunately. The same application works just fine when running against (Py)Qt5. Backtrace is the same as above, though I've also seen nonsensical overload resolution errors in the QMutexLocker constructor (with the same stack trace, presumably due to memory corruption).
I am not very familiar with the internals of Python's GC and how PyQt integrates with it – any ideas what kind of information might be helpful in tracking this down further?
Activity
awoimbee commentedon Apr 15, 2022
I have the same issue with a long running Future. I solved it by using
threading.Lock()instead ofQMutex. Not sure if this could have a negative impact.Edit: I had a freeze using
threading.Lock(), i switched tomultiprocessing.Lock(), it works well.hosaka commentedon Apr 11, 2023
It is a common problem with Qt bindings for python, where a c++ object underneath gets deleted, and python then tries to use a reference to it. This needs a bit more digging and ideally a reproducible example. Perhaps a long
sleepcall, rather than an ffmpeg encode.dnadlinger commentedon Sep 22, 2023
I'm also seeing this using (Py)Qt6 and Python 3.11 in https://github.com/dnadlinger/artiq/tree/qt6. No leads as to a reproducible example, unfortunately. The same application works just fine when running against (Py)Qt5. Backtrace is the same as above, though I've also seen nonsensical overload resolution errors in the QMutexLocker constructor (with the same stack trace, presumably due to memory corruption).
I am not very familiar with the internals of Python's GC and how PyQt integrates with it – any ideas what kind of information might be helpful in tracking this down further?
dnadlinger commentedon Oct 2, 2023
@esmorun / @awoimbee: You might want to check whether #87 fixes the issue.
hosaka commentedon Oct 2, 2023