【发布时间】:2021-01-04 20:37:24
【问题描述】:
我正在使用 PySide2 和 scikit-learn 开发一个应用程序。如果我使用单个线程,应用程序可以正常工作,但是如果我将 sckikit-learn 计算移动到工作线程 QThread(以在处理过程中保持 UI 响应),我会在 Mac OS Catalina 上遇到随机分段错误。同一个程序似乎在 Windows 上运行良好(在 Mac 上,我每隔一次运行该程序都会遇到分段错误;我在 Windows 上运行该程序至少 20 次,它从未崩溃过)。我试图遵循this answer 中的建议,但我无法让gdb 或lldb 在Catalina 上正常工作。
这就是我通过lldb 得到的:
% lldb python
(lldb) target create "python"
Current executable set to 'python' (x86_64).
(lldb) run test.py
error: process exited with status -1 (attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.))
然后我尝试使用 MacPorts 安装gdb,然后我按照instructions from the GDB Wiki 允许gdb 调试另一个进程,但是gdb 在run 命令之后挂起或给我一个未知信号错误在运行一个简单的脚本时(只打印一个字符串):
% ggdb python
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin19.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...
(No debugging symbols found in python)
(gdb) run test.py
Starting program: /usr/bin/python test.py
[New Thread 0x2603 of process 92261]
[New Thread 0x1803 of process 92261]
During startup program terminated with signal ?, Unknown signal.
有没有办法在 Catalina 上调试 Python 分段错误?
【问题讨论】:
标签: python segmentation-fault gdb lldb macos-catalina