Skip to content
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

python interactive shell crashed with munmap_chunk(): invalid pointer after installed readline. #66

Open
liudonghua123 opened this issue Dec 7, 2023 · 1 comment

Comments

@liudonghua123
Copy link

I found my python maybe lack of readline functionalities. If I entered the interactive shell, I could not use tab to do auto-completion or use navigation key like up/down to use history commands or input backspace (produce ^H). So I tried to installed readline package, but after installed, the interactive shell always crashed when execute any commands.

[root@localhost dockerfile-from-image]# python
Python 3.11.0 (main, Apr 23 2023, 12:29:15) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
>>> import rlcompleter 
>>> ^H^H^C
KeyboardInterrupt
>>> exit()
[root@localhost dockerfile-from-image]#
[root@localhost dockerfile-from-image]# pip install readline
Collecting readline
  Downloading readline-6.2.4.1.tar.gz (2.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 1.6 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: readline
  Building wheel for readline (setup.py) ... done
  Created wheel for readline: filename=readline-6.2.4.1-cp311-cp311-linux_x86_64.whl size=333498 sha256=6f19ff752265f1f078a803c0b703375d8b5bb100477c9572199f4ffde7d7b723
  Stored in directory: /root/.cache/pip/wheels/c8/81/5e/329aa6245c9520e99ef1eb24b0b360a7eaf6dabc812ffb8640
Successfully built readline
Installing collected packages: readline
Successfully installed readline-6.2.4.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.1.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
[root@localhost dockerfile-from-image]# python
Python 3.11.0 (main, Apr 23 2023, 12:29:15) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import docker
munmap_chunk(): invalid pointer
Aborted (core dumped)
[root@localhost dockerfile-from-image]#
[root@localhost dockerfile-from-image]# python
Python 3.11.0 (main, Apr 23 2023, 12:29:15) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(123)
munmap_chunk(): invalid pointer
Aborted (core dumped)
[root@localhost dockerfile-from-image]# pip uninstall readline
Found existing installation: readline 6.2.4.1
Uninstalling readline-6.2.4.1:
  Would remove:
    /usr/local/lib/python3.11/site-packages/readline-6.2.4.1.dist-info/*
    /usr/local/lib/python3.11/site-packages/readline.cpython-311-x86_64-linux-gnu.so
Proceed (Y/n)? y
  Successfully uninstalled readline-6.2.4.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
[root@localhost dockerfile-from-image]# python
Python 3.11.0 (main, Apr 23 2023, 12:29:15) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(123)
123
>>> import gnureadline as readline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gnureadline'
>>>

@ludwigschwardt
Copy link
Owner

ludwigschwardt commented Apr 19, 2024

Hi @liudonghua123, sorry for the wait, I missed this... You need to pip install gnureadline. The readline package is an older version that is deprecated. I am working on a better way to override the Python tab completion so that your use case can be achieved. Have a look at the override-readline-via-site-customization branch if you are curious.

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

No branches or pull requests

2 participants