繁体   English   中英

树莓派上的“python”命令分段错误

[英]'python' command segmentation fault on raspberry pi

我的问题相当简单:在运行 Raspbian Wheezy 的 raspberry pi 模型 A+ 上运行“python”命令(不是脚本)会出现分段错误:

pi@raspberrypi ~ $ python
Segmentation fault

我在 python 脚本中发现了很多处理“分段错误”的线程(通常与外部 C 模块相关)。 在 apt-get 升级期间,一些更具体的关于 raspberry pi 的人经常谈到“分段错误”,涉及 python 模块( 这里那里)。

但这些都没有回答我的问题。

在 gdb 中运行它给出:

pi@raspberrypi ~ $ gdb python
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 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 "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python...BFD: /usr/bin/python: invalid string offset 4204450 >= 26547 for section `.dynstr'
BFD: /usr/bin/python: invalid string offset 34425 >= 26547 for section `.dynstr'
BFD: /usr/bin/python: invalid string offset 276647 >= 26547 for section `.dynstr'
...
(50 or so such lines later)
...
BFD: /usr/bin/python: invalid string offset 2340624285 >= 26547 for section `.dynstr'
(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python 

Program received signal SIGSEGV, Segmentation fault.
0xb6ff0124 in ?? () from /lib/ld-linux-armhf.so.3
(gdb) backtrace
#0  0xb6ff0124 in ?? () from /lib/ld-linux-armhf.so.3
#1  0xbefff358 in ?? ()
Cannot access memory at address 0x7a626964

我找到了这个相关的帖子,但没有给出明确的解决方案。

最后一个元素:python3 工作得很好。

这里有人知道发生了什么吗?

谢谢你的帮助~

运行Python时从GDB获得的消息表明,由于某种原因,您尝试使用的Python可执行文件已损坏。 尝试重新安装所有与Python相关的软件包:

$ sudo apt-get install --reinstall `dpkg --get-selections | grep -E '^(lib)?python' | cut -f1 | cut -d: -f1`

我有一个类似的问题, python3是段错误,但apt无法安装或删除包,因为它调用/usr/bin/apt-listchanges ,这是一个无法执行的 Python 3 脚本。

有一次,我收到消息cannot open /var/lib/dpkg/info/parted.list (Structure needs cleaning) ,这表明存在一些文件系统损坏。 因此,如果您遇到此问题,请查看是否是这种情况。

我创建了/forcefsck文件以在下次启动时强制进行文件系统修复。 系统没有恢复——最好准备好串行电缆和备用 SD 卡。

如果它恢复正常,我会运行apt install python3-dbg来下载GDB 调试扩展,即使apt最终会崩溃——你可以使用sudo dpkg -i /var/cache/apt/archives/python3.7-dbg*.deb手动安装sudo dpkg -i /var/cache/apt/archives/python3.7-dbg*.deb

我在 Raspberry Pi 上遇到了类似的问题,就我而言是 Python2。 像@rgov 和@icktoofay 一样暗示我有一个损坏的二进制文件。 gdb 甚至不会加载二进制文件。 在强制 fsck 之后, sudo dpkg -i /var/cache/apt/python2.7*修复了这个问题,然后我就可以执行sudo apt --fix-broken install 可能是我的卡出现故障,或者电源质量低导致写入失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM