我正在使用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
,然后按照gdb
调试gdb
来调试另一个进程,但是run
要么在{{1 }}命令,或者在运行简单脚本时给我一个未知信号错误(只需打印一个字符串):
% 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分段错误?
答案 0 :(得分:2)
SIP(系统完整性保护)禁止调试器附加到系统应用程序,包括Python的出厂版本。这就是您所看到的。
您需要关闭SIP或构建自己的Python版本。 OTOH,如果您要调试-O0内置的Python,则使用Python调试问题会容易得多,因此从长远来看,弄清楚如何自己构建它(实际上并不难做到)很容易。 / p>