运行代码以使用gdb进行调试时出错: https://pastebin.ubuntu.com/p/PxrKVGmmTQ/
(gdb) run demo.py
Starting program: /usr/bin/python3 demo.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff39aa2a9 in GlobalError::PushToStack() ()
from /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0
Python堆栈跟踪: https://pastebin.ubuntu.com/p/zWz5KBdhSZ/
(gdb) py-bt
Traceback (most recent call first):
<built-in method init_config of module object at remote 0x7ffff41c70e8>
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 34, in <module>
apt_pkg.init_config()
<built-in method exec of module object at remote 0x7ffff7fd4638>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
<built-in method exec of module object at remote 0x7ffff7fd4638>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
<built-in method exec of module object at remote 0x7ffff7fd4638>
---Type <return> to continue, or q <return> to quit---
线程信息: https://pastebin.ubuntu.com/p/TYBnd3RG78/
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fdb740 (LWP 3104) "python3" 0x00007ffff39aa2a9 in GlobalError::PushToStack() () from /usr/lib/x86_64-linux-gnu/libapt-pkg.so.5.0
python代码中的当前线程: https://pastebin.ubuntu.com/p/TjvGGvGGYG/
(gdb) py-list
29 ProblemResolver # pyflakes
30 from apt.cdrom import Cdrom
31
32 # init the package system, but do not re-initialize config
33 if "APT" not in apt_pkg.config: # type: ignore
>34 apt_pkg.init_config()
35 apt_pkg.init_system()
36
37 __all__ = ['Cache', 'Cdrom', 'Package']
用于调试(按顺序)的GDB函数:
gdb python3
run <filename>.py
py-bt
info threads
py-list
我正在运行带有python绑定的自定义c ++库。 .so(共享库)文件正在动态链接到python程序。 python文件正在导入自定义c ++库。当我使用python3 filename.py
运行python文件时,收到错误消息:Segmentation fault(核心转储),我尝试使用gdb for python调试此错误。我需要帮助来了解上述链接所指向的内容以及如何解决此问题。