Debugging Segmentation fault. Help needed

Viewed 806

Error on running code to debug using 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 stack trace: 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---

Thread info: 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

Current thread in python code: 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 functions used to debug (in-order) :

gdb python3

run <filename>.py

py-bt

info threads

py-list

I am running a custom c++ library with python bindings. A .so (shared object) file is being dynamically linked to the python program. The python file is importing the custom c++ library . When I run the python file using python3 filename.py I receive the error : Segmentation fault(core dumped) I tried debugging this error using gdb for python. I need help in understanding what the above links are pointing to and how this issue can be resolved.

0 Answers
Related