我在 Ubuntu 22.04 上遇到了分段错误,想寻求帮助进行调试。
我有一些运行sudo apt-get update
:Segmentation faultsts... 52%
运行软件更新程序我得到:update-manager crashed with SIGSEV
另一个例子是删除 conda 环境。
有时在spyder中运行python脚本:
/home/max/anaconda3/envs/spyder-env/lib/python3.11/site-packages/spyder/plugins/ipythonconsole/scripts/conda-activate.sh: line 18: 1216748 Segmentation fault (core dumped) $CONDA_ENV_PYTHON -m spyder_kernels.console -f $SPYDER_KERNEL_SPEC
Fatal Python error: Segmentation fault
Main thread:
Current thread 0x00007bc69791f440 (most recent call first):
File "/media/max/Workspace/Code/attention_states/tests/../src/temporal_response_function.py", line 55 in trf_train
File "/media/max/Workspace/Code/attention_states/tests/../src/temporal_response_function.py", line 135 in trf_cross_val
File "/media/max/Workspace/Code/attention_states/tests/../src/utils.py", line 128 in trf_region
File "<stdin>", line 1 in <module>
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spyderpdb.py", line 268 in default
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/cmd.py", line 214 in onecmd
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/pdb.py", line 853 in onecmd
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spyderpdb.py", line 683 in cmdloop
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spyderpdb.py", line 653 in _cmdloop
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spyderpdb.py", line 333 in interaction
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/pdb.py", line 437 in user_line
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/bdb.py", line 122 in dispatch_line
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/bdb.py", line 96 in trace_dispatch
File "/media/max/Workspace/Code/attention_states/tests/global_signal_phonemes_all.py", line 327 in <module>
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/bdb.py", line 651 in run
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spyderpdb.py", line 900 in run
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spydercustomize.py", line 473 in exec_code
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spydercustomize.py", line 615 in _exec_file
File "/home/max/anaconda3/envs/attention_states/lib/python3.13/site-packages/spyder_kernels/customize/spydercustomize.py", line 660 in debugfile
File "/tmp/ipykernel_1216748/3781023966.py", line 1 in <module>
Restarting kernel...
此外,其他程序(如 Visual Studio 或 Google Chrome)崩溃时没有出现错误。
我试过:
- 重新安装 spyder
- 创建了一个新的 conda 环境并重新安装我使用的所有包。
- 冉
conda clean -a
- 使用 apt-get 运行更新和升级
- 运行 memtest,没有出现任何错误
- 对 CPU 进行压力测试
- 尝试在恢复模式下修复导致分段错误的损坏包。
- 更新 BIOS
- 升级到 Ubuntu 24.04
以下是删除 conda 环境时发生分段错误后出现的日志(journalctl)的摘录:
59 ip 000000000056e762 sp 00007ffe27297e60 error 6 in python3.10[41f000+1fb000] likely on CPU 4 (core 8, socket 0) Dec 02 > 16:13:52 max-workstation kernel: Code: 38 49 c7 44 24 48 00 00 00 00 48 85 ff 0f 85 9b 00 00 00 48 85 d2 0f 85 de 00 00 00 4d 85 ff 0f 85 bf 00 00 00 49 8b 4c 24 10 <48> c7 41 >
有人对如何找到这个问题的根源有什么建议吗?我也可以重新安装 Ubuntu,但我想了解发生了什么。
这似乎是 CPU 的一个错误。
如上所述,
journalctl --since "10 minutes ago" -k
显示了每个分段错误的错误。错误始终指向同一个 CPU:CPU 4 (core 8, socket 0)
通过
lscpu --all --extended
,我发现这对应于核心 2(https://stackoverflow.com/questions/71122837/how-to-detect-e-cores-and-p-cores-in-linux-alder-lake-system)。然后我就能够在 BIOS 中关闭这个核心。
对于 CPU(第 13 代 Intel Core i9-13900KF),核心 2 对应于 P 核心 2。在 BIOS(主板华硕 ROG STRIX Z690-E GAMING WIFI)中,我更改了:
高级 -> CPU 配置 -> 每个 P 核控制 -> 已启用
然后
高级 -> CPU 配置 -> P-Core 2 -> 已禁用。
系统目前运行正常,没有分段错误。