Skip to content

fix: tab completion broken with Python 3.12 #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

neurocyte
Copy link

closes #325

The fix comes from gdb upstream @ https://sourceware.org/bugzilla/show_bug.cgi?id=32473

@cyrus-and
Copy link
Owner

@ChenRuiwei can you confirm this is working for you?

@ChenRuiwei
Copy link

Yes, although GDB has reached version 16.2, the problem still persists. I had been using using import sys; sys.modules["readline"] = None as a temporary workaround, and this PR effectively resolves the issue as well.

@cyrus-and
Copy link
Owner

I'm still unable to reproduce this issue... it's not clear to me if the culprit is GDB, the Python version embedded by it, or both. I tried with several Debian and Ubuntu versions, with no luck.

For example, tab completion works here:

root@d86dd2046128:/# gdb --version
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git

root@d86dd2046128:/# gdb --batch -ex 'python import sys; print(sys.version)'
3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0]

@cyrus-and
Copy link
Owner

It seems everything is fine as long as nobody imports readline, now question is, who's importing readline? Not the dashboard, and not GDB itself in its Python code I guess, since they make the (failed) effort to forbid using readline when scripting, as mentioned in the upstream issue.

@ChenRuiwei
Copy link

This is the current environment I'm working with. I guess that Python needs to be at least version 3.13. I will try to create a Dockerfile to reproduce the issue.

❯ fastfetch
                  -`                     crw@archlinux
                 .o+`                    -------------
                `ooo/                    OS: Arch Linux x86_64
               `+oooo:                   Host: 82JQ (Lenovo Legion R9000P2021H)
              `+oooooo:                  Kernel: Linux 6.13.1-arch1-1
              -+oooooo+:                 Uptime: 8 hours, 17 mins
            `/:-:++oooo+:                Packages: 2085 (pacman)
           `/++++/+++++++:               Shell: fish 3.7.1
          `/++++++++++++++:              Display (CSO1600): 2560x1600 @ 165 Hz (as 1602x1001) in 16" [Built-in]
         `/+++ooooooooooooo/`            WM: Hyprland 0.47.2 (Wayland)
        ./ooosssso++osssssso+`           Theme: Breeze [GTK2/3]
       .oossssso-````/ossssss+`          Icons: breeze [GTK2/3/4]
      -osssssso.      :ssssssso.         Font: Noto Sans CJK SC (10pt) [GTK2/3/4]
     :osssssss/        osssso+++.        Cursor: breeze (24px)
    /ossssssss/        +ssssooo/-        Terminal: tmux 3.5a
  `/ossssso+/:-        -:/+osssso+-      CPU: AMD Ryzen 7 5800H (16) @ 4.46 GHz
 `+sso+:-`                 `.-/+oso:     GPU 1: NVIDIA GeForce RTX 3060 Mobile / Max-Q [Discrete]
`++:.                           `-/+/    GPU 2: AMD Radeon Vega Series / Radeon Vega Mobile Series [Integrated]
.`                                 `/    Memory: 5.75 GiB / 13.50 GiB (43%)
                                         Swap: 830.00 MiB / 16.00 GiB (5%)
                                         Disk (/): 95.81 GiB / 209.00 GiB (46%) - btrfs
                                         Disk (/media/gamedisk): 800.05 GiB / 953.85 GiB (84%) - fuseblk [Read-only]
                                         Local IP (wlp4s0): 192.168.1.104/24
                                         Battery (L20C4PC1): 99% [AC Connected]
                                         Locale: zh_CN.UTF-8

❯ gdb --version
GNU gdb (GDB) 16.2
Copyright (C) 2024 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.

❯ gdb --batch -ex 'python import sys; print(sys.version)'
3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910]

❯ gdb --conf
This GDB was configured as follows:
   configure --host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
             --enable-targets=all
             --with-auto-load-dir=$debugdir:$datadir/auto-load
             --with-auto-load-safe-path=$debugdir:$datadir/auto-load
             --with-expat
             --with-gdb-datadir=/usr/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/lib/gdb (relocatable)
             --without-libunwind-ia64
             --with-lzma
             --without-babeltrace
             --without-intel-pt
             --with-xxhash
             --with-python=/usr (relocatable)
             --with-python-libdir=/usr/lib (relocatable)
             --with-debuginfod
             --with-curses
             --with-guile
             --without-amd-dbgapi
             --enable-source-highlight
             --enable-threading
             --enable-tui
             --with-system-readline
             --with-separate-debug-dir=/usr/lib/debug (relocatable)
             --with-system-gdbinit=/etc/gdb/gdbinit

("Relocatable" means the directory can be moved with the GDB installation
tree, and GDB will still find it.)

GNU Readline library version: 8.2       (system)

@cyrus-and
Copy link
Owner

Tried with both:

  • Debian Sid: GDB 16.2 / Python 3.13.2
  • Ubuntu Noble: GDB 15.0.50 / Python 3.12.3

In both cases, tab completion works properly, and in both cases manually importing readline inside GDB breaks it:

>>> python import readline

@cyrus-and
Copy link
Owner

I'm trying with the following and tab completion works properly.

FROM archlinux

RUN pacman --noconfirm -Sy gdb wget
RUN wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit
[root@71108350d29a /]# gdb --version
GNU gdb (GDB) 16.2

[root@71108350d29a /]# gdb --batch -ex 'python import sys; print(sys.version)'
3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910]

@ChenRuiwei
Copy link

Try GDB 15.2 / Python 3.13.1, I tested on my computer, the bug has been reproduced.

@cyrus-and
Copy link
Owner

Do you have a reproducible way of fetching this combo? E.g., a particular version of Arch or something?

@ChenRuiwei
Copy link

install yay to activate AUR, and then use yay to install downgrade, I am trying to write them in a Dockerfile

@ChenRuiwei
Copy link

Things goes weird now. I can no not reproduce this issue in Docker, even though I've tried different versions of GDB and Python......

@cyrus-and
Copy link
Owner

You can modify the official fix to debug if you're importing readline somewhere. Assuming the exceptions get swallowed, try to put a print, a file write, or a debugger trap in place of:

raise ImportError("readline module disabled under GDB")

@ChenRuiwei
Copy link

You can modify the official fix to debug if you're importing readline somewhere. Assuming the exceptions get swallowed, try to put a print, a file write, or a debugger trap in place of:

raise ImportError("readline module disabled under GDB")

Good idea! I output the traceback into in a file when the import error raises.

# fix https://github.com/cyrus-and/gdb-dashboard/issues/325
# fix from https://sourceware.org/bugzilla/show_bug.cgi?id=32473
class GdbRemoveReadlineFinder(importlib.abc.MetaPathFinder):
    def find_spec(self, fullname, path=None, target=None):
        if fullname == "readline":
            with open('tmp', 'w') as file:
                stack = traceback.extract_stack()
                stack_info = traceback.format_list(stack)
                file.write("".join(stack_info))
            raise ImportError("readline module disabled under GDB")
        return None
❯ cat tmp
  File "<string>", line 456, in on_stop
  File "<string>", line 569, in render
  File "<string>", line 1235, in lines
  File "<string>", line 228, in __init__
  File "/usr/lib/python3.13/site-packages/pygments/lexers/__init__.py", line 225, in get_lexer_for_filename
    res = find_lexer_class_for_filename(_fn, code)
  File "/usr/lib/python3.13/site-packages/pygments/lexers/__init__.py", line 185, in find_lexer_class_for_filename
    for cls in find_plugin_lexers():
  File "/usr/lib/python3.13/site-packages/pygments/plugin.py", line 57, in find_plugin_lexers
    yield entrypoint.load()
  File "/usr/lib/python3.13/importlib/metadata/__init__.py", line 179, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/site-packages/IPython/__init__.py", line 54, in <module>
    from .core.application import Application
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/site-packages/IPython/core/application.py", line 26, in <module>
    from IPython.core import release, crashhandler
  File "<frozen importlib._bootstrap>", line 1415, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/site-packages/IPython/core/crashhandler.py", line 29, in <module>
    from IPython.core import ultratb
  File "<frozen importlib._bootstrap>", line 1415, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/site-packages/IPython/core/ultratb.py", line 111, in <module>
    from IPython.core import debugger
  File "<frozen importlib._bootstrap>", line 1415, in _handle_fromlist
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/site-packages/IPython/core/debugger.py", line 150, in <module>
    from pdb import Pdb as OldPdb
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/pdb.py", line 93, in <module>
    from rlcompleter import Completer
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.13/rlcompleter.py", line 212, in <module>
    import readline
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1322, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1262, in _find_spec
  File "<string>", line 49, in find_spec

@cyrus-and
Copy link
Owner

So it's, at least, Pygments that requires readline? Which version of Pygments are you using?

@ChenRuiwei
Copy link

Pygments is installed by pacman.

❯ pacman -Q python-pygments
python-pygments 2.19.1-1

❯ python
Python 3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygments
>>> print(pygments.__version__)
2.19.1

@ChenRuiwei
Copy link

I have reproduced the issue in Docker! After I installed all the python packages I have been installed in my host computer in Docker environment, the issue appears.

❯ pacman -Q | grep python
ipython 8.32.0-1
kdevelop-python 24.12.2-1
python 3.13.1-1
python-anyio 4.8.0-1
python-apsw 3.47.1.0-1
python-argcomplete 3.4.0-2
python-argon2-cffi 23.1.0-3
python-argon2-cffi-bindings 21.2.0-6
python-asttokens 3.0.0-1
python-async-lru 2.0.4-4
python-async-timeout 4.0.3-6
python-attrs 23.2.0-4
python-autocommand 2.2.2-7
python-automat 22.10.0-7
python-babel 2.15.0-2
python-bcrypt 4.2.1-2
python-beautifulsoup4 4.12.3-3
python-bleach 6.2.0-2
python-brotli 1.1.0-3
python-brotlicffi 1.1.0.0-3
python-cairo 1.27.0-2
python-capstone 5.0.5-1
python-certifi 2025.01.31-1
python-cffi 1.17.1-2
python-chardet 5.2.0-6
python-charset-normalizer 3.4.1-1
python-click 8.1.7-4
python-colorama 0.4.6-5
python-colored-traceback 0.3.0-6
python-comm 0.2.2-3
python-constantly 23.10.4-2
python-cryptography 44.0.0-1
python-css-parser 1.0.10-3
python-cssselect 1.2.0-8
python-dateutil 2.9.0-6
python-dbus 1.3.2-5
python-decorator 5.1.1-5
python-defusedxml 0.7.1-7
python-deprecated 1.2.15-2
python-dnspython 1:2.7.0-1
python-docopt 0.6.2-14
python-executing 2.2.0-1
python-fastjsonschema 2.21.1-1
python-faust-cchardet 2.1.19-3
python-feedparser 6.0.11-3
python-filelock 3.17.0-1
python-gobject 3.50.0-2
python-h11 0.14.0-6
python-html2text 2024.2.26-2
python-html5-parser 0.4.12-3
python-html5lib 1.1-15
python-httpcore 1.0.7-2
python-httpx 0.28.1-2
python-hyperlink 21.0.0-7
python-idna 3.10-2
python-ifaddr 0.2.0-6
python-importlib-metadata 7.2.1-4
python-incremental 22.10.0-7
python-inflate64 1.0.1-1
python-intervaltree 3.1.0-9
python-ipykernel 6.29.5-3
python-jaconv 0.3.4-3
python-jaraco.collections 5.1.0-1
python-jaraco.context 6.0.1-1
python-jaraco.functools 4.1.0-1
python-jaraco.text 4.0.0-2
python-jedi 0.19.2-1
python-jeepney 0.8.0-4
python-jinja 1:3.1.5-1
python-json-logger 3.2.1-1
python-json5 0.10.0-2
python-jsonschema 4.23.0-2
python-jsonschema-specifications 2024.10.1-1
python-jupyter-client 8.6.3-3
python-jupyter-core 5.7.2-3
python-jupyter-events 0.12.0-1
python-jupyterlab-server 2.27.3-3
python-lxml 5.3.0-2
python-lxml-html-clean 0.2.0-2
python-mako 1.3.8-1
python-markdown 3.7-2
python-markdown-it-py 3.0.0-4
python-markupsafe 2.1.5-3
python-matplotlib-inline 0.1.7-2
python-mdurl 0.1.2-8
python-mechanize 1:0.4.10-2
python-mistune 1:3.1.1-1
python-more-itertools 10.5.0-1
python-msgpack 1.0.5-3
python-multivolumefile 0.2.3-9
python-nest-asyncio 1.6.0-4
python-netifaces 0.11.0-7
python-ordered-set 4.1.0-7
python-overrides 7.7.0-3
python-packaging 24.2-3
python-pandocfilters 1.5.1-3
python-paramiko 3.5.0-1
python-parso 1:0.8.4-3
python-pdftotext 2.2.2-9
python-pexpect 4.9.0-4
python-pillow 11.1.0-1
python-pip 25.0-1
python-platformdirs 4.3.6-2
python-plumbum 1.9.0-2
python-prometheus_client 0.21.1-1
python-prompt_toolkit 3.0.50-1
python-psutil 6.1.1-1
python-pt r20240401.114.50227bd-2
python-ptrace 0.9.9-4
python-ptyprocess 0.7.0-8
python-pure-eval 0.2.3-2
python-pwntools 4.14.0-1
python-py7zr 0.22.0-4
python-pybcj 1.0.3-1
python-pychm 0.8.6-9
python-pycparser 2.22-3
python-pycryptodome 3.21.0-3
python-pycryptodomex 3.21.0-2
python-pyelftools 0.31-3
python-pygdbmi 0.11.0.0-5
python-pygments 2.19.1-1
python-pykakasi 2.3.0-2
python-pynacl 1.5.0-3
python-pyppmd 1.1.1-1
python-pyqt5 5.15.11-2
python-pyqt5-sip 12.17.0-1
python-pyqt6 6.8.1-1
python-pyqt6-sip 13.10.0-1
python-pyqt6-webengine 6.8.0-2
python-pyserial 3.5-7
python-pysocks 1.7.1-10
python-pytz 2024.2-2
python-pywal 3.3.0-10
python-pyzmq 26.2.0-1
python-pyzstd 0.16.2-2
python-qtpy 2.4.2-1
python-referencing 0.35.1-3
python-regex 2024.11.6-2
python-requests 2.32.3-4
python-rich 13.9.4-3
python-rpds-py 0.22.3-1
python-rpyc 6.0.1-2
python-ruamel-yaml 0.18.10-1
python-ruamel.yaml.clib 0.2.12-3
python-send2trash 1.8.3-2
python-sentry_sdk 2.20.0-1
python-setuptools 1:75.2.0-4
python-sgmllib3k 1.0.0-7
python-six 1.17.0-1
python-sniffio 1.3.1-4
python-sortedcontainers 2.4.0-7
python-soupsieve 2.6-2
python-stack-data 0.6.3-4
python-tabulate 0.9.0-5
python-texttable 1.7.0-3
python-tinycss2 1.4.0-2
python-tomli 2.0.1-5
python-tornado 6.4.2-1
python-traitlets 5.14.3-3
python-trove-classifiers 2025.1.15.22-1
python-twisted 24.3.0-4
python-typing_extensions 4.12.2-3
python-uc-micro-py 1.0.3-3
python-unicorn 2.1.1-1
python-unrardll 0.1.7-4
python-urllib3 2.3.0-1
python-validate-pyproject 0.23-1
python-wcwidth 0.2.13-3
python-webencodings 0.5.1-12
python-websocket-client 1.8.0-2
python-websockets 12.0-3
python-wheel 0.45.0-3
python-wrapt 1.16.0-4
python-xxhash 3.5.0-1
python-yaml 6.0.2-2
python-ytmusicapi 1.10.1-1
python-zeroconf 0.136.2-1
python-zipp 3.21.0-2
python-zope-interface 7.2-1
python-zstandard 0.23.0-2

❯ pacman -Q | grep python | cut --delimiter " " --fields 1 | tr '\n' ' '
ipython kdevelop-python python python-anyio python-apsw python-argcomplete python-argon2-cffi python-argon2-cffi-bindings python-asttokens python-async-lru python-async-timeout python-attrs python-autocommand python-automat python-babel python-bcrypt python-beautifulsoup4 python-bleach python-brotli python-brotlicffi python-cairo python-capstone python-certifi python-cffi python-chardet python-charset-normalizer python-click python-colorama python-colored-traceback python-comm python-constantly python-cryptography python-css-parser python-cssselect python-dateutil python-dbus python-decorator python-defusedxml python-deprecated python-dnspython python-docopt python-executing python-fastjsonschema python-faust-cchardet python-feedparser python-filelock python-gobject python-h11 python-html2text python-html5-parser python-html5lib python-httpcore python-httpx python-hyperlink python-idna python-ifaddr python-importlib-metadata python-incremental python-inflate64 python-intervaltree python-ipykernel python-jaconv python-jaraco.collections python-jaraco.context python-jaraco.functools python-jaraco.text python-jedi python-jeepney python-jinja python-json-logger python-json5 python-jsonschema python-jsonschema-specifications python-jupyter-client python-jupyter-core python-jupyter-events python-jupyterlab-server python-lxml python-lxml-html-clean python-mako python-markdown python-markdown-it-py python-markupsafe python-matplotlib-inline python-mdurl python-mechanize python-mistune python-more-itertools python-msgpack python-multivolumefile python-nest-asyncio python-netifaces python-ordered-set python-overrides python-packaging python-pandocfilters python-paramiko python-parso python-pdftotext python-pexpect python-pillow python-pip python-platformdirs python-plumbum python-prometheus_client python-prompt_toolkit python-psutil python-pt python-ptrace python-ptyprocess python-pure-eval python-pwntools python-py7zr python-pybcj python-pychm python-pycparser python-pycryptodome python-pycryptodomex python-pyelftools python-pygdbmi python-pygments python-pykakasi python-pynacl python-pyppmd python-pyqt5 python-pyqt5-sip python-pyqt6 python-pyqt6-sip python-pyqt6-webengine python-pyserial python-pysocks python-pytz python-pywal python-pyzmq python-pyzstd python-qtpy python-referencing python-regex python-requests python-rich python-rpds-py python-rpyc python-ruamel-yaml python-ruamel.yaml.clib python-send2trash python-sentry_sdk python-setuptools python-sgmllib3k python-six python-sniffio python-sortedcontainers python-soupsieve python-stack-data python-tabulate python-texttable python-tinycss2 python-tomli python-tornado python-traitlets python-trove-classifiers python-twisted python-typing_extensions python-uc-micro-py python-unicorn python-unrardll python-urllib3 python-validate-pyproject python-wcwidth python-webencodings python-websocket-client python-websockets python-wheel python-wrapt python-xxhash python-yaml python-ytmusicapi python-zeroconf python-zipp python-zope-interface python-zstandard ⏎

@cyrus-and
Copy link
Owner

Can you share the Dockerfile if you have one?

@ChenRuiwei
Copy link

May be this would be OK, I have'nt tested it yet in one Dockerfile though, the network is quite unstable that I can not build it quickly.

FROM archlinux:latest

RUN pacman-key --init

RUN pacman -Syu --noconfirm

RUN pacman -S --noconfirm gcc make perl wget git python gdb

RUN pacman -S --noconfirm ipython kdevelop-python python python-anyio python-apsw python-argcomplete python-argon2-cffi python-argon2-cffi-bindings python-asttokens python-async-lru python-async-timeout python-attrs python-autocommand python-automat python-babel python-bcrypt python-beautifulsoup4 python-bleach python-brotli python-brotlicffi python-cairo python-capstone python-certifi python-cffi python-chardet python-charset-normalizer python-click python-colorama python-colored-traceback python-comm python-constantly python-cryptography python-css-parser python-cssselect python-dateutil python-dbus python-decorator python-defusedxml python-deprecated python-dnspython python-docopt python-executing python-fastjsonschema python-faust-cchardet python-feedparser python-filelock python-gobject python-h11 python-html2text python-html5-parser python-html5lib python-httpcore python-httpx python-hyperlink python-idna python-ifaddr python-importlib-metadata python-incremental python-inflate64 python-intervaltree python-ipykernel python-jaconv python-jaraco.collections python-jaraco.context python-jaraco.functools python-jaraco.text python-jedi python-jeepney python-jinja python-json-logger python-json5 python-jsonschema python-jsonschema-specifications python-jupyter-client python-jupyter-core python-jupyter-events python-jupyterlab-server python-lxml python-lxml-html-clean python-mako python-markdown python-markdown-it-py python-markupsafe python-matplotlib-inline python-mdurl python-mechanize python-mistune python-more-itertools python-msgpack python-multivolumefile python-nest-asyncio python-netifaces python-ordered-set python-overrides python-packaging python-pandocfilters python-paramiko python-parso python-pdftotext python-pexpect python-pillow python-pip python-platformdirs python-plumbum python-prometheus_client python-prompt_toolkit python-psutil python-pt python-ptrace python-ptyprocess python-pure-eval python-pwntools python-py7zr python-pybcj python-pychm python-pycparser python-pycryptodome python-pycryptodomex python-pyelftools python-pygdbmi python-pygments python-pykakasi python-pynacl python-pyppmd python-pyqt5 python-pyqt5-sip python-pyqt6 python-pyqt6-sip python-pyqt6-webengine python-pyserial python-pysocks python-pytz python-pywal python-pyzmq python-pyzstd python-qtpy python-referencing python-regex python-requests python-rich python-rpds-py python-rpyc python-ruamel-yaml python-ruamel.yaml.clib python-send2trash python-sentry_sdk python-setuptools python-sgmllib3k python-six python-sniffio python-sortedcontainers python-soupsieve python-stack-data python-tabulate python-texttable python-tinycss2 python-tomli python-tornado python-traitlets python-trove-classifiers python-twisted python-typing_extensions python-uc-micro-py python-unicorn python-unrardll python-urllib3 python-validate-pyproject python-wcwidth python-webencodings python-websocket-client python-websockets python-wheel python-wrapt python-xxhash python-yaml python-ytmusicapi python-zeroconf python-zipp python-zope-interface python-zstandard

RUN wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit

@ChenRuiwei
Copy link

After checking the backtrace again, it is IPython who imports readline. This is the minimal example by far I have tested.

FROM archlinux:latest

RUN pacman-key --init

RUN pacman -Syu --noconfirm

RUN pacman -S --noconfirm gcc make perl wget git python gdb

RUN wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit && \
    pacman -S --noconfirm python-pygments ipython

@cyrus-and
Copy link
Owner

cyrus-and commented Feb 9, 2025

Phew, so it seems it's both:

  • having IPython installed;
  • using Pygments and debugging a C file (or maybe another language, e.g., it doesn't happen with just ASM).

I can automatically reproduce this with:

FROM debian:sid

ARG DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt --yes install gdb wget python3-pip vim
RUN wget -P ~ https://github.com/cyrus-and/gdb-dashboard/raw/master/.gdbinit
RUN python3 -m pip install --break-system-packages pygments==2.19.1
RUN printf '#include <stdio.h>\nint main() {printf("asd");}' >main.c
RUN gcc -g main.c

RUN apt --yes install ipython3

ENTRYPOINT ["gdb", "-ex", "start", "a.out"]

cyrus-and added a commit that referenced this pull request Feb 9, 2025
So it seems that importing readline causes issue with the GDB prompt, in fact
GDB already tries (failing) to avoid that. The issue manifests when debugging a
program with the source code available, e.g., C, and IPython is available in the
system.

Close #325 #326
cyrus-and added a commit that referenced this pull request Feb 9, 2025
So it seems that importing readline causes issue with the GDB prompt, in fact
GDB already tries (failing) to avoid that. The issue manifests when debugging a
program with the source code available, e.g., C, and IPython is available in the
system.

Close #325, #326
@cyrus-and cyrus-and closed this in 616ed51 Feb 9, 2025
@cyrus-and
Copy link
Owner

Thank you @neurocyte, but I like @ChenRuiwei's solution better.

@patryk4815
Copy link

patryk4815 commented Feb 17, 2025

please write more comments in https://sourceware.org/bugzilla/show_bug.cgi?id=32473
so somebody will fix it in upstream. Right now nobody complaining...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tab completion breaks
4 participants