Python 程序因 ntdll.dll 和 QtGui4.dll 而崩溃

Python program crashes because of ntdll.dll and QtGui4.dll

我设计了一个 Python 软件来从我的微控制器收集数据并制作实时绘图:

我的 GUI 中有十二个 matplotlib 动画(GUI 是用 PyQt 设计的)。每个 matplotlib 动画都连接到一个 TCP 线程,通过该线程接收浮点数 link。收到浮点数后,matplotlib 动画会向图形添加一个新点。欢呼,我们有现场直播!

我的软件可以流畅运行几秒钟(有时长达半分钟)。然后灾难降临。 Windows 提到 "Python has stopped working"。我什至没有在我的终端 window 中打印异常报告(因为它通常会发生在我的所有其他错误上)。 Windows 问我是否要调试 Python 应用程序,并建议为此使用 Visual Basic。在 Visual Basic 中,我收到以下错误报告:

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.

我重启一切,再试一次。灾难再次降临,我在 Visual Basic 中得到如下错误报告:

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

再一次,我重新开始尝试。灾难再次降临:

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

不幸的是,我不知道这些错误报告是什么意思。我用谷歌搜索了 QtGui4.dllntdll.dll。我找到了几个程序来修复我计算机上的 dll,但 Norton 防病毒软件告诉我我不能信任它们。所以我现在别无选择,只能求助于 Whosebug。

在此先感谢您的帮助。

编辑 : 我已经按照你的建议通过 matplotlib.use("Qt4Agg") 更改了 matplotlib 后端,但没有帮助。

我相信这个问题现在已经解决了。这是问题的根本原因。我以线程不安全的方式从另一个线程访问了我的 GUI(例如实时图、LED 等)。该应用程序在一段时间内(半分钟)运行良好,但后来不可避免地崩溃了。

我通过signal/slot机制修复了它。这就是(对另一个 Whosebug 问题的 link):

对于给您带来的不便,我们深表歉意。