PySide6 application silent crash in windows 11
-
Hi all.
I have developed a pyside6 desktop application that interfaces with a camera and records the feeds from the camera. While testing the app in windows 11, I am seeing silent crashes. It crashes at random times, sometimes when the app just starts recording, sometimes the app crashes after recording for a long time.
There is not error shown in QTCreator, nor in the command prompt. I checked windows event viewer and got the following error
Faulting application name: python.exe, version: 3.11.1150.1013, time stamp: 0x638f9f80 Faulting module name: Qt6Gui.dll, version: 6.4.2.0, time stamp: 0x63970839 Exception code: 0xc0000005 Fault offset: 0x00000000001438ab Faulting process id: 0x0x460 Faulting application start time: 0x0x1D9392C9C7B2869 Faulting application path: C:\Program Files\Python311\python.exe Faulting module path: C:\Users\Amaldev\AppData\Roaming\Python\Python311\site-packages\PySide6\Qt6Gui.dll Report Id: a1afc3fe-74e6-461c-8dd5-c82452c6e366 Faulting package full name: Faulting package-relative application ID:
From the details in the event viewer I could figure out the crash happened from inside the Qt6Gui.dll file and the exception code 0xc0000005 means there is some memory access violation. How do I figure what exactly is wrong?
Is this a known issue in windows 11 or could it be something wrong in the code?
Thanks in advance
-
Hi all.
I have developed a pyside6 desktop application that interfaces with a camera and records the feeds from the camera. While testing the app in windows 11, I am seeing silent crashes. It crashes at random times, sometimes when the app just starts recording, sometimes the app crashes after recording for a long time.
There is not error shown in QTCreator, nor in the command prompt. I checked windows event viewer and got the following error
Faulting application name: python.exe, version: 3.11.1150.1013, time stamp: 0x638f9f80 Faulting module name: Qt6Gui.dll, version: 6.4.2.0, time stamp: 0x63970839 Exception code: 0xc0000005 Fault offset: 0x00000000001438ab Faulting process id: 0x0x460 Faulting application start time: 0x0x1D9392C9C7B2869 Faulting application path: C:\Program Files\Python311\python.exe Faulting module path: C:\Users\Amaldev\AppData\Roaming\Python\Python311\site-packages\PySide6\Qt6Gui.dll Report Id: a1afc3fe-74e6-461c-8dd5-c82452c6e366 Faulting package full name: Faulting package-relative application ID:
From the details in the event viewer I could figure out the crash happened from inside the Qt6Gui.dll file and the exception code 0xc0000005 means there is some memory access violation. How do I figure what exactly is wrong?
Is this a known issue in windows 11 or could it be something wrong in the code?
Thanks in advance
@ajithkgshk
Hello and welcome.I would expect this to show up in a debugger with perhaps some further useful information. Did you try running your application under the Python debugger and/or running the
python.exe
process under a C++/Windows debugger to see what you get? -
@ajithkgshk
Hello and welcome.I would expect this to show up in a debugger with perhaps some further useful information. Did you try running your application under the Python debugger and/or running the
python.exe
process under a C++/Windows debugger to see what you get?Hi @JonB . I tried debugging using windbg. I am not getting any more details except this. I am attaching the screenshot of the debugger. I am guessing there is no further info since the call crashes from within a dll file.
Any tips of how I can dig into the dll file during execution to figure out who is calling the QVectorPath::convertToPainterPath function
-
Hi @JonB . I tried debugging using windbg. I am not getting any more details except this. I am attaching the screenshot of the debugger. I am guessing there is no further info since the call crashes from within a dll file.
Any tips of how I can dig into the dll file during execution to figure out who is calling the QVectorPath::convertToPainterPath function
@ajithkgshk
If windbg cannot display a stack trace then you need to use a debugger like VS/MSVC. Whether it will show you back into calling code outside the DLL I cannot say, you may also need to have compiled for debug. -
@ajithkgshk
If windbg cannot display a stack trace then you need to use a debugger like VS/MSVC. Whether it will show you back into calling code outside the DLL I cannot say, you may also need to have compiled for debug.@JonB Do you mean pyside has to be compiled for debug? since the DLL file is provided by pyside, it needs to be compiled for debug correct?
-
@JonB Do you mean pyside has to be compiled for debug? since the DLL file is provided by pyside, it needs to be compiled for debug correct?
@ajithkgshk
We don't know yet. First thing is to try to see whether with a different debugger you can get a stack trace when it crashes, leading back into your code. Debug might be necessary/wanted for variable values, but you may not get that far anyway. -
@ajithkgshk
We don't know yet. First thing is to try to see whether with a different debugger you can get a stack trace when it crashes, leading back into your code. Debug might be necessary/wanted for variable values, but you may not get that far anyway.@JonB Ok. I will try VS or MSVC. I will keep posting the updates here.
By the way, just for information's sake, the app is rock stable in Windows 10 and Linux. There are no crashes that happen in this regard. We are seeing the crash behavior only in windows 11
-
I have figured out why the application was crashing. The app is threaded, one thread to capture an image from an industrial camera and submits to a queue, another thread to process the images and updates a label used as an image view.
The image view is updated by converting the image into a pixmap and then set the pixmap to the label.
We had assumed that the final draw call QT does to show the updated image was done synchronously. But it is not. The reference of the image was being lost and GCed before the draw call was made.
I solved the issue by holding reference of the images in a cache for about 5 seconds before clearing it from the cache.
Edit: Do not know why the app was not crashing in windows 10. It could be that thread scheduling in Win 11 is different from Win 10 and that is causing the UI thread to complete drawing before the next update.
-
I have figured out why the application was crashing. The app is threaded, one thread to capture an image from an industrial camera and submits to a queue, another thread to process the images and updates a label used as an image view.
The image view is updated by converting the image into a pixmap and then set the pixmap to the label.
We had assumed that the final draw call QT does to show the updated image was done synchronously. But it is not. The reference of the image was being lost and GCed before the draw call was made.
I solved the issue by holding reference of the images in a cache for about 5 seconds before clearing it from the cache.
Edit: Do not know why the app was not crashing in windows 10. It could be that thread scheduling in Win 11 is different from Win 10 and that is causing the UI thread to complete drawing before the next update.
@ajithkgshk hi, that lifetime issue is described in the constructor of the QPixmap you are using. One other way to that is to send a copy of the QPixmap when you call the signal. It might be slower though.