Python program crashes because of ntdll.dll and QtGui4.dll
Asked Answered
P

1

0

I have designed a Python software to collect data from my microcontroller and make live plots:

enter image description here

I have twelve matplotlib animations in my GUI (the GUI is designed with PyQt). Each matplotlib animation is connected to one TCP thread, receiving floating point numbers through that link. Upon receiving a floating point number, the matplotlib animation adds a new point to the graph. And huray, we got live plots!

My software runs smoothly for a couple of seconds (sometimes up to half a minute). And then disaster strikes. Windows mentions "Python has stopped working". I don't even get an exception report printed in my terminal window (as it normally would happen for all my other bugs). Windows asks me if I want to debug the Python application, and suggests to use Visual Basic for that. In Visual Basic, I get the following error report:

Unhandled exception at 0x00007FFC596CE6FC (ntdll.dll) in
python.exe: 0xC0000374: A heap has been corrupted
(parameters: 0x00007FFC597222B0).

Unhandled exception at 0x00007FFC56071F28 in python.exe:
Microsoft C++ exception: std::bad_alloc at memory
location 0x0000003DBA30E8F0.

Exception thrown at 0x0000000000000000 in python.exe:
0xC0000005: Access violation executing location
0x0000000000000000.

I restart everything, and try it once more. Disaster strikes again, and I get the following error report in Visual Basic:

Unhandled exception at 0x00000000660E8D61 (QtGui4.dll) in python.exe:
0xC0000005: Access violation reading location 0x0000000000000020.

Once again, I restart for another trial. Disaster hits me again:

Unhandled exception at 0x00007FFC596CE6FC (ntdll.dll) in python.exe:
0xC0000374: A heap has been corrupted (parameters: 0x00007FFC597222B0).

Unfortunately, I have no clue what these error reports mean. I have googled QtGui4.dlland ntdll.dll. I found a couple of programs to fix dll's on my computer, but Norton antivirus tells me that I cannot trust them. So I'm out of options now, and turn to StackOverflow as my last resort.

Thanks in advance for your help.

EDIT : I have followed your advice to change the matplotlib backend through matplotlib.use("Qt4Agg"), but it didn't help.

Ponzo answered 15/5, 2016 at 19:37 Comment(2)
Hmm, I would try changing the backend of matplotlib with matplotlib.use("Qt4Agg"). Then I would try using plt.pause instead of time.sleep.Cairns
Thank you so much. I'm now going to sleep, but tomorrow morning I will try it out.Ponzo
P
2

I believe that the issue is fixed now. This was the root cause of the problem. I accessed my GUI (for example the live plots, the LEDs, ..) from another thread, in a thread-unsafe way. The application works good for some time (half a minute), but inevitably crashes miserably later on.

I fixed it through using the signal/slot mechanism. This is how (a link to another StackOverflow question):

Simplest way for PyQT Threading

I'm sorry for the inconvenience.

Ponzo answered 16/5, 2016 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.